diff options
author | Felipe Artur <felipefac@gmail.com> | 2017-06-07 18:14:23 -0300 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2017-06-16 11:59:39 -0300 |
commit | 86fc145c3c0c5056d7c6be1d62cd0b5beec2b1a9 (patch) | |
tree | bffa58304afe9cb8e0d0e9e9a632a49389934e67 /app/models/concerns/milestoneish.rb | |
parent | ff7fe2d12dec6c76b5a90b2c95cca81152cc5d42 (diff) | |
download | gitlab-ce-86fc145c3c0c5056d7c6be1d62cd0b5beec2b1a9.tar.gz |
Order issues by priority
Diffstat (limited to 'app/models/concerns/milestoneish.rb')
-rw-r--r-- | app/models/concerns/milestoneish.rb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/app/models/concerns/milestoneish.rb b/app/models/concerns/milestoneish.rb index a3472af5c55..2b177641ecc 100644 --- a/app/models/concerns/milestoneish.rb +++ b/app/models/concerns/milestoneish.rb @@ -1,7 +1,7 @@ module Milestoneish def closed_items_count(user) memoize_per_user(user, :closed_items_count) do - (count_issues_by_state(user)['closed'] || 0) + merge_requests.closed_and_merged.size + (count_issues_by_state(user)['closed'].count || 0) + merge_requests.closed_and_merged.size end end @@ -12,7 +12,7 @@ module Milestoneish end def total_issues_count(user) - count_issues_by_state(user).values.sum + issues_visible_to_user(user).length end def complete?(user) @@ -39,8 +39,8 @@ module Milestoneish def issues_visible_to_user(user) memoize_per_user(user, :issues_visible_to_user) do - IssuesFinder.new(user, issues_finder_params) - .execute.includes(:assignees).where(milestone_id: milestoneish_ids) + IssuesFinder.new(user, issues_finder_params.merge({ sort: 'priority'})) + .execute.preload(:assignees).where(milestone_id: milestoneish_ids) end end @@ -66,7 +66,9 @@ module Milestoneish def count_issues_by_state(user) memoize_per_user(user, :count_issues_by_state) do - issues_visible_to_user(user).reorder(nil).group(:state).count + # Need to group and count using ruby array to not break + # label ordering + issues_visible_to_user(user).to_a.group_by(&:state) end end |