diff options
Diffstat (limited to 'app/models/environment.rb')
-rw-r--r-- | app/models/environment.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/app/models/environment.rb b/app/models/environment.rb index 2d480345b5a..b29543ded32 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -11,6 +11,7 @@ class Environment < ApplicationRecord has_many :deployments, -> { visible }, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent has_many :successful_deployments, -> { success }, class_name: 'Deployment' + has_many :prometheus_alerts, inverse_of: :environment has_one :last_deployment, -> { success.order('deployments.id DESC') }, class_name: 'Deployment' has_one :last_deployable, through: :last_deployment, source: 'deployable', source_type: 'CommitStatus' @@ -105,6 +106,14 @@ class Environment < ApplicationRecord find_or_create_by(name: name) end + def clear_prometheus_reactive_cache!(query_name) + cluster_prometheus_adapter&.clear_prometheus_reactive_cache!(query_name, self) + end + + def cluster_prometheus_adapter + @cluster_prometheus_adapter ||= ::Gitlab::Prometheus::Adapter.new(project, deployment_platform&.cluster).cluster_prometheus_adapter + end + def predefined_variables Gitlab::Ci::Variables::Collection.new .append(key: 'CI_ENVIRONMENT_NAME', value: name) |