Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-09-13 03:10:14 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-09-13 03:10:14 +0300
commit7e87cfd402a5faba6e1287e150702ca51156eac4 (patch)
treeff2e46a3a91cf013d8930c6e8a5ba5e3cdf39330 /app/models/environment.rb
parent3b69a04945341516a2ed6a291769c50fe04336df (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/environment.rb')
-rw-r--r--app/models/environment.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/app/models/environment.rb b/app/models/environment.rb
index 03e92d8722f..34cab11a879 100644
--- a/app/models/environment.rb
+++ b/app/models/environment.rb
@@ -30,6 +30,16 @@ class Environment < ApplicationRecord
has_one :last_deployment, -> { success.ordered }, class_name: 'Deployment', inverse_of: :environment
has_one :last_visible_deployment, -> { visible.order(id: :desc) }, inverse_of: :environment, class_name: 'Deployment'
+ Deployment::FINISHED_STATUSES.each do |status|
+ has_one :"last_#{status}_deployment", -> { where(status: status).ordered },
+ class_name: 'Deployment', inverse_of: :environment
+ end
+
+ Deployment::UPCOMING_STATUSES.each do |status|
+ has_one :"last_#{status}_deployment", -> { where(status: status).ordered_as_upcoming },
+ class_name: 'Deployment', inverse_of: :environment
+ end
+
has_one :upcoming_deployment, -> { upcoming.order(id: :desc) }, class_name: 'Deployment', inverse_of: :environment
has_one :latest_opened_most_severe_alert, -> { order_severity_with_open_prometheus_alert }, class_name: 'AlertManagement::Alert', inverse_of: :environment