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>2021-12-09 15:15:43 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-12-09 15:15:43 +0300
commit15f5da601b5dd687f9fc1a1da71d791c8c3e6411 (patch)
treea7ee75c2bfbd841e3854e8ee86fc17eaedd15b65 /lib/gitlab/relative_positioning
parent3d233a67cf4ab39773e3ee10a09df9eb7c3b4167 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/relative_positioning')
-rw-r--r--lib/gitlab/relative_positioning/item_context.rb22
1 files changed, 6 insertions, 16 deletions
diff --git a/lib/gitlab/relative_positioning/item_context.rb b/lib/gitlab/relative_positioning/item_context.rb
index 1e738aef9b0..98e52e8e767 100644
--- a/lib/gitlab/relative_positioning/item_context.rb
+++ b/lib/gitlab/relative_positioning/item_context.rb
@@ -66,19 +66,11 @@ module Gitlab
end
def lhs_neighbour
- scoped_items
- .where('relative_position < ?', relative_position)
- .reorder(relative_position: :desc)
- .first
- .then { |x| neighbour(x) }
+ neighbour(object.next_object_by_relative_position(ignoring: ignoring, order: :desc))
end
def rhs_neighbour
- scoped_items
- .where('relative_position > ?', relative_position)
- .reorder(relative_position: :asc)
- .first
- .then { |x| neighbour(x) }
+ neighbour(object.next_object_by_relative_position(ignoring: ignoring, order: :asc))
end
def neighbour(item)
@@ -87,12 +79,6 @@ module Gitlab
self.class.new(item, range, ignoring: ignoring)
end
- def scoped_items
- r = model_class.relative_positioning_query_base(object)
- r = object.exclude_self(r, excluded: ignoring) if ignoring.present?
- r
- end
-
def calculate_relative_position(calculation)
# When calculating across projects, this is much more efficient than
# MAX(relative_position) without the GROUP BY, due to index usage:
@@ -186,6 +172,10 @@ module Gitlab
Gap.new(gap.first, gap.second || default_end)
end
+ def scoped_items
+ object.relative_positioning_scoped_items(ignoring: ignoring)
+ end
+
def relative_position
object.relative_position
end