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:
authorFelipe Artur <fcardozo@gitlab.com>2018-07-30 16:44:41 +0300
committerPhil Hughes <me@iamphill.com>2018-07-30 16:44:41 +0300
commit5815c5b48ac03dbd89a239e87c0f49216a428563 (patch)
tree7af892c202f2e00ee79d2646d5429ee466ff3ded /app/services/boards
parent4f08343463d6a987ad3415d410b38b4f9dde67a2 (diff)
[Backport] View summed weights of issues in board column
Diffstat (limited to 'app/services/boards')
-rw-r--r--app/services/boards/issues/list_service.rb27
1 files changed, 24 insertions, 3 deletions
diff --git a/app/services/boards/issues/list_service.rb b/app/services/boards/issues/list_service.rb
index 50c11be0d15..0db1418b37a 100644
--- a/app/services/boards/issues/list_service.rb
+++ b/app/services/boards/issues/list_service.rb
@@ -3,14 +3,35 @@
module Boards
module Issues
class ListService < Boards::BaseService
+ include Gitlab::Utils::StrongMemoize
+
def execute
- issues = IssuesFinder.new(current_user, filter_params).execute
- issues = filter(issues)
- issues.order_by_position_and_priority
+ fetch_issues.order_by_position_and_priority
+ end
+
+ def metadata
+ keys = metadata_fields.keys
+ columns = metadata_fields.values_at(*keys).join(', ')
+ results = Issue.where(id: fetch_issues.select('issues.id')).pluck(columns)
+
+ Hash[keys.zip(results.flatten)]
end
private
+ def metadata_fields
+ { size: 'COUNT(*)' }
+ end
+
+ # We memoize the query here since the finder methods we use are quite complex. This does not memoize the result of the query.
+ def fetch_issues
+ strong_memoize(:fetch_issues) do
+ issues = IssuesFinder.new(current_user, filter_params).execute
+
+ filter(issues).reorder(nil)
+ end
+ end
+
def filter(issues)
issues = without_board_labels(issues) unless list&.movable? || list&.closed?
issues = with_list_label(issues) if list&.label?