From 77237c5a6b9044f58beabc54d3589e5fa09cbfba Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 5 Mar 2020 00:07:49 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- app/models/concerns/milestoneish.rb | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'app/models/concerns') diff --git a/app/models/concerns/milestoneish.rb b/app/models/concerns/milestoneish.rb index 88e752e51e7..045e893761a 100644 --- a/app/models/concerns/milestoneish.rb +++ b/app/models/concerns/milestoneish.rb @@ -2,13 +2,27 @@ module Milestoneish def total_issues_count(user) - count_issues_by_state(user).values.sum + @total_issues_count ||= + if Feature.enabled?(:cached_milestone_issue_counters) + Milestones::IssuesCountService.new(self).count + else + count_issues_by_state(user).values.sum + end end def closed_issues_count(user) - closed_state_id = Issue.available_states[:closed] + @close_issues_count ||= + if Feature.enabled?(:cached_milestone_issue_counters) + Milestones::ClosedIssuesCountService.new(self).count + else + closed_state_id = Issue.available_states[:closed] + + count_issues_by_state(user)[closed_state_id].to_i + end + end - count_issues_by_state(user)[closed_state_id].to_i + def opened_issues_count(user) + total_issues_count(user) - closed_issues_count(user) end def complete?(user) -- cgit v1.2.1