diff options
author | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-05-09 22:24:24 +0200 |
---|---|---|
committer | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-05-11 23:07:12 +0200 |
commit | 693602d957b2bb48a5270d249a2e2708c03bd803 (patch) | |
tree | f68006a9b15cf54fde168ae9997796994bb60ed5 /app/models | |
parent | 4f824d2aecf4fec46febd767fa7f7d747c732112 (diff) | |
download | gitlab-ce-693602d957b2bb48a5270d249a2e2708c03bd803.tar.gz |
Keep presentation logic in one place and remove unecessary arguments.
+ fix tests
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/deployment.rb | 3 | ||||
-rw-r--r-- | app/models/project_services/prometheus_service.rb | 5 |
2 files changed, 4 insertions, 4 deletions
diff --git a/app/models/deployment.rb b/app/models/deployment.rb index f4751dc5334..216cec751e3 100644 --- a/app/models/deployment.rb +++ b/app/models/deployment.rb @@ -106,8 +106,7 @@ class Deployment < ActiveRecord::Base def metrics return {} unless has_metrics? - metrics = project.monitoring_service.deployment_metrics(self) - metrics&.merge(deployment_time: created_at.to_i) || {} + project.monitoring_service.deployment_metrics(self) end private diff --git a/app/models/project_services/prometheus_service.rb b/app/models/project_services/prometheus_service.rb index 23e19bedf3f..ec72cb6856d 100644 --- a/app/models/project_services/prometheus_service.rb +++ b/app/models/project_services/prometheus_service.rb @@ -63,12 +63,13 @@ class PrometheusService < MonitoringService { success: false, result: err } end - def environment_metrics(environment, **args) + def environment_metrics(environment) with_reactive_cache(Gitlab::Prometheus::Queries::EnvironmentQuery.name, environment.id, &:itself) end def deployment_metrics(deployment) - with_reactive_cache(Gitlab::Prometheus::Queries::DeploymentQuery.name, deployment.id, &:itself) + metrics = with_reactive_cache(Gitlab::Prometheus::Queries::DeploymentQuery.name, deployment.id, &:itself) + metrics&.merge(deployment_time: created_at.to_i) || {} end # Cache metrics for specific environment |