Optimize relative re-positioning
What does this MR do?
Moving of neighbour items was done recursively - this was extremely expensive when multiple items had to be moved.
This change optimizes the code to find nearest possible gap where items can be moved and moves all of them with single update query.
For example, supposing there is a sequence of positions 10 11 12 13 14 15
and are moving an issue between positions 14
and 15
:
Then old solution was: Try to move 14
to 13
and because 13
is not free, recursively continue with moving 13 -> 12
, 12 -> 11
, 11 -> 10
, 10 -> X
.
Now the behavior is:
If there is no free position between 14
and 15
, then find whole sequence of positions without gap which have to be moved to move 14
and then move the whole sequence to the middle of the gap - in this case it finds sequence 14..10
and gap is 0..10
, so it moves positions 14..10
to 9..5
.
Related to https://gitlab.com/gitlab-org/gitlab-ce/issues/64514
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry for user-facing changes, or community contribution. Check the link for other scenarios. -
Documentation created/updated or follow-up review issue created -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Performance and testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team