Fix issuable state counter cache keys
These cache a hash of counts by state, so the state isn't needed in the key itself.
This commit is contained in:
parent
11f9ac0a48
commit
c57ae83dcf
|
@ -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? }
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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…
Reference in New Issue