diff options
Diffstat (limited to 'app/models/concerns/milestoneish.rb')
-rw-r--r-- | app/models/concerns/milestoneish.rb | 38 |
1 files changed, 10 insertions, 28 deletions
diff --git a/app/models/concerns/milestoneish.rb b/app/models/concerns/milestoneish.rb index 045e893761a..6dbb9649b9f 100644 --- a/app/models/concerns/milestoneish.rb +++ b/app/models/concerns/milestoneish.rb @@ -1,36 +1,24 @@ # frozen_string_literal: true module Milestoneish - def total_issues_count(user) - @total_issues_count ||= - if Feature.enabled?(:cached_milestone_issue_counters) - Milestones::IssuesCountService.new(self).count - else - count_issues_by_state(user).values.sum - end + def total_issues_count + @total_issues_count ||= Milestones::IssuesCountService.new(self).count end - def closed_issues_count(user) - @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 + def closed_issues_count + @close_issues_count ||= Milestones::ClosedIssuesCountService.new(self).count end - def opened_issues_count(user) - total_issues_count(user) - closed_issues_count(user) + def opened_issues_count + total_issues_count - closed_issues_count end - def complete?(user) - total_issues_count(user) > 0 && total_issues_count(user) == closed_issues_count(user) + def complete? + total_issues_count > 0 && total_issues_count == closed_issues_count end - def percent_complete(user) - closed_issues_count(user) * 100 / total_issues_count(user) + def percent_complete + closed_issues_count * 100 / total_issues_count rescue ZeroDivisionError 0 end @@ -135,12 +123,6 @@ module Milestoneish Gitlab::TimeTrackingFormatter.output(total_issue_time_estimate) end - def count_issues_by_state(user) - memoize_per_user(user, :count_issues_by_state) do - issues_visible_to_user(user).reorder(nil).group(:state_id).count - end - end - private def memoize_per_user(user, method_name) |