Skip to content
Snippets Groups Projects
Commit c57ae83d authored by Sean McGivern's avatar Sean McGivern
Browse files

Fix issuable state counter cache keys

These cache a hash of counts by state, so the state isn't needed in the key
itself.
parent 11f9ac0a
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -20,7 +20,7 @@
#
class IssuableFinder
include CreatedAtFilter
NONE = '0'.freeze
IRRELEVANT_PARAMS_FOR_CACHE_KEY = %i[utf8 sort page].freeze
 
Loading
Loading
@@ -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
Loading
Loading
@@ -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? }
 
Loading
Loading
Loading
Loading
@@ -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)
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment