summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2017-07-11 13:19:43 +0100
committerSean McGivern <sean@gitlab.com>2017-07-19 10:21:18 +0100
commitc57ae83dcfaeff9c358b5f896202e04a86ad6ef3 (patch)
tree183f7f8c2b37a760964afcb939f1db9cd20c59f8
parent11f9ac0a48b62cef25eedede4c1819964f08d5ce (diff)
downloadgitlab-ce-c57ae83dcfaeff9c358b5f896202e04a86ad6ef3.tar.gz
Fix issuable state counter cache keys
These cache a hash of counts by state, so the state isn't needed in the key itself.
-rw-r--r--app/finders/issuable_finder.rb9
-rw-r--r--app/finders/issues_finder.rb2
-rw-r--r--app/helpers/issuables_helper.rb2
3 files changed, 6 insertions, 7 deletions
diff --git a/app/finders/issuable_finder.rb b/app/finders/issuable_finder.rb
index 2e5a6493134..1585c11ab3a 100644
--- a/app/finders/issuable_finder.rb
+++ b/app/finders/issuable_finder.rb
@@ -20,7 +20,7 @@
#
class IssuableFinder
include CreatedAtFilter
-
+
NONE = '0'.freeze
IRRELEVANT_PARAMS_FOR_CACHE_KEY = %i[utf8 sort page].freeze
@@ -89,8 +89,8 @@ class IssuableFinder
execute.find_by!(*params)
end
- def state_counter_cache_key(state)
- Digest::SHA1.hexdigest(state_counter_cache_key_components(state).flatten.join('-'))
+ def state_counter_cache_key
+ Digest::SHA1.hexdigest(state_counter_cache_key_components.flatten.join('-'))
end
def group
@@ -417,9 +417,8 @@ class IssuableFinder
params[:scope] == 'created-by-me' || params[:scope] == 'authored' || params[:scope] == 'assigned-to-me'
end
- def state_counter_cache_key_components(state)
+ def state_counter_cache_key_components
opts = params.with_indifferent_access
- opts[:state] = state
opts.except!(*IRRELEVANT_PARAMS_FOR_CACHE_KEY)
opts.delete_if { |_, value| value.blank? }
diff --git a/app/finders/issues_finder.rb b/app/finders/issues_finder.rb
index 85230ff1293..295a64ef5b8 100644
--- a/app/finders/issues_finder.rb
+++ b/app/finders/issues_finder.rb
@@ -75,7 +75,7 @@ class IssuesFinder < IssuableFinder
current_user.blank? || for_counting || params[:for_counting]
end
- def state_counter_cache_key_components(state)
+ def state_counter_cache_key_components
extra_components = [
user_can_see_all_confidential_issues?,
user_cannot_see_confidential_issues?(for_counting: true)
diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb
index d0c518f81f7..425af547330 100644
--- a/app/helpers/issuables_helper.rb
+++ b/app/helpers/issuables_helper.rb
@@ -235,7 +235,7 @@ module IssuablesHelper
def issuables_count_for_state(issuable_type, state, finder: nil)
finder ||= public_send("#{issuable_type}_finder")
- cache_key = finder.state_counter_cache_key(state)
+ cache_key = finder.state_counter_cache_key
@counts ||= {}
@counts[cache_key] ||= Rails.cache.fetch(cache_key, expires_in: 2.minutes) do