summaryrefslogtreecommitdiff
path: root/app/services/boards
diff options
context:
space:
mode:
authorFelipe Artur <fcardozo@gitlab.com>2018-07-30 13:44:41 +0000
committerPhil Hughes <me@iamphill.com>2018-07-30 13:44:41 +0000
commit5815c5b48ac03dbd89a239e87c0f49216a428563 (patch)
tree7af892c202f2e00ee79d2646d5429ee466ff3ded /app/services/boards
parent4f08343463d6a987ad3415d410b38b4f9dde67a2 (diff)
downloadgitlab-ce-5815c5b48ac03dbd89a239e87c0f49216a428563.tar.gz
[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?