diff options
author | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-06-16 20:48:34 +0200 |
---|---|---|
committer | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-06-16 20:48:34 +0200 |
commit | 6e4d5334211d73dd731cb8757b2ef10e8ea428b7 (patch) | |
tree | f48f5b8582bd9ff93b8e58182cd5018eda6a82f4 /app/models | |
parent | be5f665557fc4f5b10d34f407545486746af54b8 (diff) | |
download | gitlab-ce-6e4d5334211d73dd731cb8757b2ef10e8ea428b7.tar.gz |
Move Prometheus service to project model
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/deployment.rb | 12 | ||||
-rw-r--r-- | app/models/environment.rb | 8 | ||||
-rw-r--r-- | app/models/project.rb | 4 |
3 files changed, 12 insertions, 12 deletions
diff --git a/app/models/deployment.rb b/app/models/deployment.rb index 04d08f2cfd5..00bf0c118ae 100644 --- a/app/models/deployment.rb +++ b/app/models/deployment.rb @@ -114,17 +114,17 @@ class Deployment < ActiveRecord::Base project.monitoring_service.deployment_metrics(self) end + def has_additional_metrics? + project.prometheus_service.present? + end + def additional_metrics - return {} unless prometheus_service.present? + return {} unless project.prometheus_service.present? - metrics = prometheus_service.additional_deployment_metrics(self) + metrics = project.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 diff --git a/app/models/environment.rb b/app/models/environment.rb index 62db7e958ab..b391a487b30 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -158,19 +158,15 @@ class Environment < ActiveRecord::Base end def has_additional_metrics? - prometheus_service.present? && available? && last_deployment.present? + project.prometheus_service.present? && available? && last_deployment.present? end def additional_metrics if has_additional_metrics? - prometheus_service.additional_environment_metrics(self) + project.prometheus_service.additional_environment_metrics(self) end end - def prometheus_service - @prometheus_service ||= project.monitoring_services.reorder(nil).find_by(active: true, type: PrometheusService.name) - end - # An environment name is not necessarily suitable for use in URLs, DNS # or other third-party contexts, so provide a slugified version. A slug has # the following properties: diff --git a/app/models/project.rb b/app/models/project.rb index 4c394646787..f6338b92b9f 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -798,6 +798,10 @@ class Project < ActiveRecord::Base @monitoring_service ||= monitoring_services.reorder(nil).find_by(active: true) end + def prometheus_service + @prometheus_service ||= monitoring_services.find_by(active: true, type: PrometheusService.name) + end + def jira_tracker? issues_tracker.to_param == 'jira' end |