diff options
Diffstat (limited to 'app/services/groups')
-rw-r--r-- | app/services/groups/open_issues_count_service.rb | 27 | ||||
-rw-r--r-- | app/services/groups/update_shared_runners_service.rb | 9 |
2 files changed, 31 insertions, 5 deletions
diff --git a/app/services/groups/open_issues_count_service.rb b/app/services/groups/open_issues_count_service.rb index 17cf3d38987..c18d239998b 100644 --- a/app/services/groups/open_issues_count_service.rb +++ b/app/services/groups/open_issues_count_service.rb @@ -3,11 +3,15 @@ module Groups # Service class for counting and caching the number of open issues of a group. class OpenIssuesCountService < Groups::CountService - PUBLIC_COUNT_KEY = 'group_public_open_issues_count' - TOTAL_COUNT_KEY = 'group_total_open_issues_count' + # TOTAL_COUNT_KEY includes confidential and hidden issues (admin) + # TOTAL_COUNT_WITHOUT_HIDDEN_KEY includes confidential issues but not hidden issues (reporter and above) + # PUBLIC_COUNT_WITHOUT_HIDDEN_KEY does not include confidential or hidden issues (guest) + TOTAL_COUNT_KEY = 'group_open_issues_including_hidden_count' + TOTAL_COUNT_WITHOUT_HIDDEN_KEY = 'group_open_issues_without_hidden_count' + PUBLIC_COUNT_WITHOUT_HIDDEN_KEY = 'group_open_public_issues_without_hidden_count' def clear_all_cache_keys - [cache_key(PUBLIC_COUNT_KEY), cache_key(TOTAL_COUNT_KEY)].each do |key| + [cache_key(TOTAL_COUNT_KEY), cache_key(TOTAL_COUNT_WITHOUT_HIDDEN_KEY), cache_key(PUBLIC_COUNT_WITHOUT_HIDDEN_KEY)].each do |key| Rails.cache.delete(key) end end @@ -15,7 +19,19 @@ module Groups private def cache_key_name - public_only? ? PUBLIC_COUNT_KEY : TOTAL_COUNT_KEY + if include_hidden? + TOTAL_COUNT_KEY + elsif public_only? + PUBLIC_COUNT_WITHOUT_HIDDEN_KEY + else + TOTAL_COUNT_WITHOUT_HIDDEN_KEY + end + end + + def include_hidden? + strong_memoize(:user_is_admin) do + user&.can_admin_all_resources? + end end def public_only? @@ -35,7 +51,8 @@ module Groups state: 'opened', non_archived: true, include_subgroups: true, - public_only: public_only? + public_only: public_only?, + include_hidden: include_hidden? ).execute end diff --git a/app/services/groups/update_shared_runners_service.rb b/app/services/groups/update_shared_runners_service.rb index 639c5bf6ae0..eb6b46a5613 100644 --- a/app/services/groups/update_shared_runners_service.rb +++ b/app/services/groups/update_shared_runners_service.rb @@ -8,6 +8,7 @@ module Groups validate_params update_shared_runners + update_pending_builds! success @@ -26,5 +27,13 @@ module Groups def update_shared_runners group.update_shared_runners_setting!(params[:shared_runners_setting]) end + + def update_pending_builds! + return unless group.previous_changes.include?('shared_runners_enabled') + + update_params = { instance_runners_enabled: group.shared_runners_enabled } + + ::Ci::UpdatePendingBuildService.new(group, update_params).execute + end end end |