diff options
author | Jose Ivan Vargas Lopez <jvargas@gitlab.com> | 2017-06-07 23:31:06 +0000 |
---|---|---|
committer | Jose Ivan Vargas Lopez <jvargas@gitlab.com> | 2017-06-07 23:31:06 +0000 |
commit | fb80347dc00657ba36576f1f23bd42fdbcf9520a (patch) | |
tree | 2642ac39cda31e29ea80defdc71e00c89ac8979e /app/models/deployment.rb | |
parent | 73924cc51495f5f497114ed9f9de02f8b9c4205b (diff) | |
parent | 6eb96b2019d392d906a64108dbe83b3ce7cce758 (diff) | |
download | gitlab-ce-additional-metrics-dashboard.tar.gz |
Merge branch '28717-additional-metrics-review-branch' into 'additional-metrics-dashboard'additional-metrics-dashboard
# Conflicts:
# app/assets/stylesheets/pages/environments.scss
Diffstat (limited to 'app/models/deployment.rb')
-rw-r--r-- | app/models/deployment.rb | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/app/models/deployment.rb b/app/models/deployment.rb index f49410f18ae..fe7fa4e66b7 100644 --- a/app/models/deployment.rb +++ b/app/models/deployment.rb @@ -12,6 +12,7 @@ class Deployment < ActiveRecord::Base delegate :name, to: :environment, prefix: true after_create :create_ref + after_create :invalidate_cache def commit project.commit(sha) @@ -33,6 +34,10 @@ class Deployment < ActiveRecord::Base project.repository.create_ref(ref, ref_path) end + def invalidate_cache + environment.expire_etag_cache + end + def manual_actions @manual_actions ||= deployable.try(:other_actions) end @@ -103,10 +108,6 @@ class Deployment < ActiveRecord::Base project.monitoring_service.present? end - def has_additional_metrics? - has_metrics? && project.monitoring_service&.respond_to?(:reactive_query) - end - def metrics return {} unless has_metrics? @@ -114,11 +115,16 @@ class Deployment < ActiveRecord::Base end def additional_metrics - return {} unless has_additional_metrics? - metrics = project.monitoring_service.reactive_query(Gitlab::Prometheus::Queries::AdditionalMetricsDeploymentQuery.name, id, &:itself) + return {} unless prometheus_service.present? + + metrics = prometheus_service.additional_deployment_metrics(self) metrics&.merge(deployment_time: created_at.to_i) || {} end + def prometheus_service + @prometheus_service ||= project.monitoring_services.reorder(nil).find_by(active: true, type: PrometheusService.name) + end + private def ref_path |