diff options
author | Josh Frye <joshfng@gmail.com> | 2016-06-01 19:27:21 -0400 |
---|---|---|
committer | Josh Frye <joshfng@gmail.com> | 2016-06-02 09:13:59 -0400 |
commit | 8835b7889a6265aba3c6d7ee241abf80a1cf07f3 (patch) | |
tree | 3aa27ff37269152c6f24e1038461acd84f12389e /app/models/user.rb | |
parent | bfccea370310d6f7e5fe16c846ccd073d487a97f (diff) | |
download | gitlab-ce-8835b7889a6265aba3c6d7ee241abf80a1cf07f3.tar.gz |
Flush cache in callback. Add tests
Diffstat (limited to 'app/models/user.rb')
-rw-r--r-- | app/models/user.rb | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 55f8e149629..172845c9d25 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -776,18 +776,23 @@ class User < ActiveRecord::Base notification_settings.find_or_initialize_by(source: source) end - def assigned_open_merge_request_count - Rails.cache.fetch(['users', id, 'assigned_open_merge_request_count'], expires_in: 60) do + def assigned_open_merge_request_count(force: false) + Rails.cache.fetch(['users', id, 'assigned_open_merge_request_count'], force: force) do assigned_merge_requests.opened.count end end - def assigned_open_issues_count - Rails.cache.fetch(['users', id, 'assigned_open_issues_count'], expires_in: 60) do + def assigned_open_issues_count(force: false) + Rails.cache.fetch(['users', id, 'assigned_open_issues_count'], force: force) do assigned_issues.opened.count end end + def update_cache_counts + assigned_open_merge_request_count(force: true) + assigned_open_issues_count(force: true) + end + private def projects_union |