diff options
author | Sean McGivern <sean@gitlab.com> | 2017-09-04 10:53:01 +0100 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2017-09-04 10:53:01 +0100 |
commit | 8e7666a488dd1bed415e0a384b044a6f832333cc (patch) | |
tree | 534638725b73b273d7c8317bc4e756711a6d93ec | |
parent | ccbdeea0a9482272bec29a3e6075969d97bd2d44 (diff) | |
download | gitlab-ce-memoize-issuable-counts-in-helper.tar.gz |
Memoize issuable counts in helpermemoize-issuable-counts-in-helper
This prevents queries being run, even if they do hit AR's query cache.
-rw-r--r-- | app/helpers/issuables_helper.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb index d81ba2c06eb..0748e748738 100644 --- a/app/helpers/issuables_helper.rb +++ b/app/helpers/issuables_helper.rb @@ -240,7 +240,10 @@ module IssuablesHelper def issuables_count_for_state(issuable_type, state) finder = public_send("#{issuable_type}_finder") # rubocop:disable GitlabSecurity/PublicSend - finder.count_by_state[state] + + @counts ||= {} + @counts[issuable_type] ||= finder.count_by_state + @counts[issuable_type][state] end def close_issuable_url(issuable) |