Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-10-21 10:08:36 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-10-21 10:08:36 +0300
commit48aff82709769b098321c738f3444b9bdaa694c6 (patch)
treee00c7c43e2d9b603a5a6af576b1685e400410dee /spec/lib/gitlab/relative_positioning/mover_spec.rb
parent879f5329ee916a948223f8f43d77fba4da6cd028 (diff)
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.0-rc42
Diffstat (limited to 'spec/lib/gitlab/relative_positioning/mover_spec.rb')
-rw-r--r--spec/lib/gitlab/relative_positioning/mover_spec.rb17
1 files changed, 5 insertions, 12 deletions
diff --git a/spec/lib/gitlab/relative_positioning/mover_spec.rb b/spec/lib/gitlab/relative_positioning/mover_spec.rb
index c49230c2415..dafd34585a8 100644
--- a/spec/lib/gitlab/relative_positioning/mover_spec.rb
+++ b/spec/lib/gitlab/relative_positioning/mover_spec.rb
@@ -37,18 +37,11 @@ RSpec.describe RelativePositioning::Mover do
end
def set_positions(positions)
- vals = issues.zip(positions).map do |issue, pos|
- issue.relative_position = pos
- "(#{issue.id}, #{pos})"
- end.join(', ')
-
- Issue.connection.exec_query(<<~SQL, 'set-positions')
- WITH cte(cte_id, new_pos) AS (
- SELECT * FROM (VALUES #{vals}) as t (id, pos)
- )
- UPDATE issues SET relative_position = new_pos FROM cte WHERE id = cte_id
- ;
- SQL
+ mapping = issues.zip(positions).to_h do |issue, pos|
+ [issue, { relative_position: pos }]
+ end
+
+ ::Gitlab::Database::BulkUpdate.execute([:relative_position], mapping)
end
def ids_in_position_order