diff options
author | Thong Kuah <tkuah@gitlab.com> | 2019-07-08 00:19:21 +0300 |
---|---|---|
committer | Thong Kuah <tkuah@gitlab.com> | 2019-07-08 00:19:21 +0300 |
commit | 792455450a1934181369412bc5ba4082c832ed86 (patch) | |
tree | e59147bc2c75e0cb046e4e410f5c66c02781dba1 /app/models/environment_status.rb | |
parent | c85d6b0c744e9a971fafdf58328f907dfa0de127 (diff) |
BE feedback: memoize deployment_metrics
Also memoize has_metrics? as well, that might be expensive, and it
should not change for the lifetime of EnvironmentStatus
Diffstat (limited to 'app/models/environment_status.rb')
-rw-r--r-- | app/models/environment_status.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/app/models/environment_status.rb b/app/models/environment_status.rb index 1b3c094901b..465a42759df 100644 --- a/app/models/environment_status.rb +++ b/app/models/environment_status.rb @@ -34,7 +34,9 @@ class EnvironmentStatus end def has_metrics? - DeploymentMetrics.new(project, deployment).has_metrics? + strong_memoize(:has_metrics) do + deployment_metrics.has_metrics? + end end def changes @@ -52,6 +54,10 @@ class EnvironmentStatus PAGE_EXTENSIONS = /\A\.(s?html?|php|asp|cgi|pl)\z/i.freeze + def deployment_metrics + @deployment_metrics ||= DeploymentMetrics.new(project, deployment) + end + def build_change(file) public_path = project.public_path_for_source_path(file.new_path, sha) return if public_path.nil? |