Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2017-07-11 19:12:33 +0300
committerSean McGivern <sean@gitlab.com>2017-07-19 12:21:20 +0300
commit0e488ef70ab2608847423201e957693745f1e3b1 (patch)
tree1b7a329505c1a3026a777258040a3f5be9870561 /app/finders
parentb3a588bccaaa078a81e8ce322d75ee167f642e13 (diff)
Clear issuable counter caches on update
When an issuable's state changes, or one is created, we should clear the cache counts for a user's assigned issuables, and also the project-wide caches for this user type.
Diffstat (limited to 'app/finders')
-rw-r--r--app/finders/issuable_finder.rb16
-rw-r--r--app/finders/issues_finder.rb10
2 files changed, 25 insertions, 1 deletions
diff --git a/app/finders/issuable_finder.rb b/app/finders/issuable_finder.rb
index d3010eff262..fc63e30c8fb 100644
--- a/app/finders/issuable_finder.rb
+++ b/app/finders/issuable_finder.rb
@@ -90,7 +90,13 @@ class IssuableFinder
end
def state_counter_cache_key
- Digest::SHA1.hexdigest(state_counter_cache_key_components.flatten.join('-'))
+ cache_key(state_counter_cache_key_components)
+ end
+
+ def clear_caches!
+ state_counter_cache_key_components_permutations.each do |components|
+ Rails.cache.delete(cache_key(components))
+ end
end
def group
@@ -424,4 +430,12 @@ class IssuableFinder
['issuables_count', klass.to_ability_name, opts.sort]
end
+
+ def state_counter_cache_key_components_permutations
+ [state_counter_cache_key_components]
+ end
+
+ def cache_key(components)
+ Digest::SHA1.hexdigest(components.flatten.join('-'))
+ end
end
diff --git a/app/finders/issues_finder.rb b/app/finders/issues_finder.rb
index 295a64ef5b8..0ec42a4e6eb 100644
--- a/app/finders/issues_finder.rb
+++ b/app/finders/issues_finder.rb
@@ -84,6 +84,16 @@ class IssuesFinder < IssuableFinder
super + extra_components
end
+ def state_counter_cache_key_components_permutations
+ # Ignore the last two, as we'll provide both options for them.
+ components = super.first[0..-3]
+
+ [
+ components + [false, true],
+ components + [true, false]
+ ]
+ end
+
def by_assignee(items)
if assignee
items.assigned_to(assignee)