debian-mirror-gitlab/app/services/groups/open_issues_count_service.rb

34 lines
857 B
Ruby
Raw Normal View History

2021-03-11 19:13:27 +05:30
# frozen_string_literal: true
module Groups
# Service class for counting and caching the number of open issues of a group.
2021-04-29 21:17:54 +05:30
class OpenIssuesCountService < Groups::CountService
2021-03-11 19:13:27 +05:30
PUBLIC_COUNT_KEY = 'group_public_open_issues_count'
TOTAL_COUNT_KEY = 'group_total_open_issues_count'
private
def cache_key_name
public_only? ? PUBLIC_COUNT_KEY : TOTAL_COUNT_KEY
end
def public_only?
!user_is_at_least_reporter?
end
def user_is_at_least_reporter?
strong_memoize(:user_is_at_least_reporter) do
group.member?(user, Gitlab::Access::REPORTER)
end
end
def relation_for_count
IssuesFinder.new(user, group_id: group.id, state: 'opened', non_archived: true, include_subgroups: true, public_only: public_only?).execute
end
2021-04-29 21:17:54 +05:30
def issuable_key
'open_issues'
end
2021-03-11 19:13:27 +05:30
end
end