Commit f558ca40 authored by Stan Hu's avatar Stan Hu

Memoize namespace monthly usage to reduce SQL queries

This eliminates an extra subtransaction and an unnecessary SELECT query.
Previously we would call `namespace_usage` twice. Wihle `project_usage`
was memoized, `namespace_usage` was not.

Changelog: performance
parent d5ae78b0
...@@ -58,8 +58,10 @@ module Ci ...@@ -58,8 +58,10 @@ module Ci
end end
def namespace_usage def namespace_usage
strong_memoize(:namespace_usage) do
::Ci::Minutes::NamespaceMonthlyUsage.find_or_create_current(namespace_id: @namespace_id) ::Ci::Minutes::NamespaceMonthlyUsage.find_or_create_current(namespace_id: @namespace_id)
end end
end
def project_usage def project_usage
strong_memoize(:project_usage) do strong_memoize(:project_usage) do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment