this integral $\int\frac{2-\sin{x}}{\sin^2{x}-\sin{x}+1}dx$ Find integral
$$\int\dfrac{2-\sin{x}}{\sin^2{x}-\sin{x}+1}dx$$
As suggested ,we take the Weierstrass Substitution is often useful in integrals such as the original.
$$
\begin{align}
\sin(x)&=\frac{2z}{1+z^2}\\
\cos(x)&=\frac{1-z^2}{1+z^2}\\
\mathrm{d}x&=\frac{2\,\mathrm{d}z}{1+z^2}
\end{align}
$$
I known is equal to
$$\int\dfrac{4(z^2-z+1)}{z^4-2z^3+6z^2-2z+1}dz$$
but I don't know how I should calculate the last integral.

Here's my revised solution that is shorter in working (which is still ridiculously long). The only tedious part is the simplifiying of the integrand after the Weierstrass Substitution. Outline:
Let $ y = \frac \pi 2 - x $, we get 
$ \begin{eqnarray} \displaystyle \int \frac{\cos y - 2}{\cos^2 y - \cos y + 1} \, dy & = & \displaystyle \int \frac{(-\sin y) + (\sin y + \cos y - 2)}{\cos^2 y - \cos y + 1} \, dy \\ & = & \int \frac{-\sin y}{\cos^2 y - \cos y + 1} \, dy + \int \frac{\sin y + \cos y - 2} {\cos^2 y - \cos y + 1} \, dy \end{eqnarray} $
The first integral can be solved via substitution of $ p = -\cos y $ then convert it in the form of $ \large\displaystyle \int \frac{ds}{a^2+s^2} = \frac1a \tan^{-1} \left( \frac sa\right) $
For the second integral, we use the  Weierstrass Substitution as suggested. Let $ t = \tan\left( \frac y2\right) $ and the integrand simplifies to
$ \large \frac{-6t^2+4t-2}{(t^2+1)^2} $
Apply partial fraction
$ \large \frac{4t}{(t^2+1)^2} - \frac6{t^2+1} + \frac4{(t^2+1)^2} $
Which can be easily integrated.
If I'm correct, back substituting everything yields
$ \large \frac2{\sqrt3} \tan^{-1} \left(\frac2{\sqrt3}\sin x\right) - \frac{2(\sin x + 1)}{\tan \frac x2 + 1} - 4\cot^{-1} x + C $
