diff options
author | Felipe Artur <felipefac@gmail.com> | 2018-06-22 20:17:03 +0300 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2018-06-25 17:54:11 +0300 |
commit | 625957c2ad70e5af03c988744ff3d4112d84e998 (patch) | |
tree | 1c3a6928552954ada8a2554c20aa35f3fd1ac45f /app/services/projects | |
parent | 4ab1011d427687b44ed937684c1a5a364d156a70 (diff) |
BatchOpenIssuesCount only updates public issues count
Diffstat (limited to 'app/services/projects')
-rw-r--r-- | app/services/projects/batch_open_issues_count_service.rb | 7 | ||||
-rw-r--r-- | app/services/projects/open_issues_count_service.rb | 22 |
2 files changed, 15 insertions, 14 deletions
diff --git a/app/services/projects/batch_open_issues_count_service.rb b/app/services/projects/batch_open_issues_count_service.rb index 1e00da04197..3b0ade2419b 100644 --- a/app/services/projects/batch_open_issues_count_service.rb +++ b/app/services/projects/batch_open_issues_count_service.rb @@ -3,11 +3,10 @@ # because the service use maps to retrieve the project ids module Projects class BatchOpenIssuesCountService < Projects::BatchCountService - - # Method not needed. Cache here is updated using - # overloaded OpenIssuesCount#refresh_cache method def global_count - nil + @global_count ||= begin + count_service.query(project_ids).group(:project_id).count + end end def count_service diff --git a/app/services/projects/open_issues_count_service.rb b/app/services/projects/open_issues_count_service.rb index e70ee86f644..78b1477186a 100644 --- a/app/services/projects/open_issues_count_service.rb +++ b/app/services/projects/open_issues_count_service.rb @@ -40,19 +40,21 @@ module Projects cache_key(TOTAL_COUNT_KEY) end - # The block passed as parameter is ignored because we need to refresh both - # cache keys on every case. def refresh_cache(&block) - count_grouped_by_confidential = self.class.query(@project, public_only: false).group(:confidential).count - public_count = count_grouped_by_confidential[false] || 0 - total_count = public_count + (count_grouped_by_confidential[true] || 0) + if block_given? + super(&block) + else + count_grouped_by_confidential = self.class.query(@project, public_only: false).group(:confidential).count + public_count = count_grouped_by_confidential[false] || 0 + total_count = public_count + (count_grouped_by_confidential[true] || 0) - update_cache_for_key(public_count_cache_key) do - public_count - end + update_cache_for_key(public_count_cache_key) do + public_count + end - update_cache_for_key(total_count_cache_key) do - total_count + update_cache_for_key(total_count_cache_key) do + total_count + end end end |