diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 10:34:06 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 10:34:06 +0000 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /app/helpers/groups_helper.rb | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) | |
download | gitlab-ce-859a6fb938bb9ee2a317c46dfa4fcc1af49608f0.tar.gz |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'app/helpers/groups_helper.rb')
-rw-r--r-- | app/helpers/groups_helper.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/app/helpers/groups_helper.rb b/app/helpers/groups_helper.rb index 133d9d21a14..eeeffb7b3ae 100644 --- a/app/helpers/groups_helper.rb +++ b/app/helpers/groups_helper.rb @@ -62,6 +62,14 @@ module GroupsHelper can?(current_user, :set_emails_disabled, group) && !group.parent&.emails_disabled? end + def group_open_issues_count(group) + if Feature.enabled?(:cached_sidebar_open_issues_count, group) + cached_open_group_issues_count(group) + else + number_with_delimiter(group_issues_count(state: 'opened')) + end + end + def group_issues_count(state:) IssuesFinder .new(current_user, group_id: @group.id, state: state, non_archived: true, include_subgroups: true) @@ -69,6 +77,21 @@ module GroupsHelper .count end + def cached_open_group_issues_count(group) + count_service = Groups::OpenIssuesCountService + issues_count = count_service.new(group, current_user).count + + if issues_count > count_service::CACHED_COUNT_THRESHOLD + ActiveSupport::NumberHelper + .number_to_human( + issues_count, + units: { thousand: 'k', million: 'm' }, precision: 1, significant: false, format: '%n%u' + ) + else + number_with_delimiter(issues_count) + end + end + def group_merge_requests_count(state:) MergeRequestsFinder .new(current_user, group_id: @group.id, state: state, non_archived: true, include_subgroups: true) |