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,7 +58,9 @@ module Ci
end
def namespace_usage
::Ci::Minutes::NamespaceMonthlyUsage.find_or_create_current(namespace_id: @namespace_id)
strong_memoize(:namespace_usage) do
::Ci::Minutes::NamespaceMonthlyUsage.find_or_create_current(namespace_id: @namespace_id)
end
end
def project_usage
......
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