diff options
author | Josh Frye <joshfng@gmail.com> | 2016-05-31 08:58:11 -0400 |
---|---|---|
committer | Josh Frye <joshfng@gmail.com> | 2016-06-02 09:13:59 -0400 |
commit | bffe0d6325710e89e405390f4da297fb12fdc314 (patch) | |
tree | 63b577a67295349f01c917d380fb295fea55d568 /app | |
parent | f828b74483a68baaadc3a4095ec6911087995892 (diff) | |
download | gitlab-ce-bffe0d6325710e89e405390f4da297fb12fdc314.tar.gz |
Cache assigned merge request count. Closes #18036
Diffstat (limited to 'app')
-rw-r--r-- | app/models/user.rb | 6 | ||||
-rw-r--r-- | app/views/layouts/nav/_dashboard.html.haml | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 15b6cbc2255..8dde01bf355 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -776,6 +776,12 @@ 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 + assigned_merge_requests.opened.count + end + end + private def projects_union diff --git a/app/views/layouts/nav/_dashboard.html.haml b/app/views/layouts/nav/_dashboard.html.haml index 43532b0c155..e14ae850fcc 100644 --- a/app/views/layouts/nav/_dashboard.html.haml +++ b/app/views/layouts/nav/_dashboard.html.haml @@ -36,7 +36,7 @@ = icon('tasks fw') %span Merge Requests - %span.count= number_with_delimiter(current_user.assigned_merge_requests.opened.count) + %span.count= number_with_delimiter(current_user.assigned_open_merge_request_count) = nav_link(controller: :snippets) do = link_to dashboard_snippets_path, title: 'Snippets' do = icon('clipboard fw') |