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-06-16 21:25:58 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-06-16 21:25:58 +0300
commita5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch)
treefb69158581673816a8cd895f9d352dcb3c678b1e /app/services/boards
parentd16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff)
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'app/services/boards')
-rw-r--r--app/services/boards/base_item_move_service.rb9
-rw-r--r--app/services/boards/base_items_list_service.rb12
-rw-r--r--app/services/boards/issues/list_service.rb4
3 files changed, 14 insertions, 11 deletions
diff --git a/app/services/boards/base_item_move_service.rb b/app/services/boards/base_item_move_service.rb
index 28fb1e43043..dfd0002cbc9 100644
--- a/app/services/boards/base_item_move_service.rb
+++ b/app/services/boards/base_item_move_service.rb
@@ -23,14 +23,15 @@ module Boards
end
reposition_ids = move_between_ids(params)
- if reposition_ids
- attrs[:move_between_ids] = reposition_ids
- attrs.merge!(reposition_parent)
- end
+ attrs.merge!(reposition_params(reposition_ids)) if reposition_ids
attrs
end
+ def reposition_params(reposition_ids)
+ reposition_parent.merge(move_between_ids: reposition_ids)
+ end
+
def move_single_issuable(issuable, issuable_modification_params)
ability_name = :"admin_#{issuable.to_ability_name}"
return unless can?(current_user, ability_name, issuable)
diff --git a/app/services/boards/base_items_list_service.rb b/app/services/boards/base_items_list_service.rb
index cbc7a332cbe..a3e24844587 100644
--- a/app/services/boards/base_items_list_service.rb
+++ b/app/services/boards/base_items_list_service.rb
@@ -6,9 +6,9 @@ module Boards
include ActiveRecord::ConnectionAdapters::Quoting
def execute
- return items.order_closed_date_desc if list&.closed?
+ items = init_collection
- ordered_items
+ order(items)
end
# rubocop: disable CodeReuse/ActiveRecord
@@ -17,7 +17,7 @@ module Boards
keys = metadata_fields.keys
# TODO: eliminate need for SQL literal fragment
columns = Arel.sql(metadata_fields.values_at(*keys).join(', '))
- results = item_model.where(id: items.select(issuables[:id])).pluck(columns)
+ results = item_model.where(id: init_collection.select(issuables[:id])).pluck(columns)
Hash[keys.zip(results.flatten)]
end
@@ -29,7 +29,7 @@ module Boards
{ size: 'COUNT(*)' }
end
- def ordered_items
+ def order(items)
raise NotImplementedError
end
@@ -47,8 +47,8 @@ module Boards
# We memoize the query here since the finder methods we use are quite complex. This does not memoize the result of the query.
# rubocop: disable CodeReuse/ActiveRecord
- def items
- strong_memoize(:items) do
+ def init_collection
+ strong_memoize(:init_collection) do
filter(finder.execute).reorder(nil)
end
end
diff --git a/app/services/boards/issues/list_service.rb b/app/services/boards/issues/list_service.rb
index 6284e454561..0e95bf7a434 100644
--- a/app/services/boards/issues/list_service.rb
+++ b/app/services/boards/issues/list_service.rb
@@ -11,7 +11,9 @@ module Boards
private
- def ordered_items
+ def order(items)
+ return items.order_closed_date_desc if list&.closed?
+
items.order_by_position_and_priority(with_cte: params[:search].present?)
end