diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 17:34:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 17:34:42 +0300 |
commit | 9f46488805e86b1bc341ea1620b866016c2ce5ed (patch) | |
tree | f9748c7e287041e37d6da49e0a29c9511dc34768 /app/models/environment.rb | |
parent | dfc92d081ea0332d69c8aca2f0e745cb48ae5e6d (diff) |
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
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 b2391f33aca..21044771bbb 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -8,6 +8,7 @@ class Environment < ApplicationRecord self.reactive_cache_refresh_interval = 1.minute self.reactive_cache_lifetime = 55.seconds self.reactive_cache_hard_limit = 10.megabytes + self.reactive_cache_work_type = :external_dependency belongs_to :project, required: true @@ -151,6 +152,14 @@ class Environment < ApplicationRecord .preload(:user, :metadata, :deployment) end + def count_by_state + environments_count_by_state = group(:state).count + + valid_states.each_with_object({}) do |state, count_hash| + count_hash[state] = environments_count_by_state[state.to_s] || 0 + end + end + private def cte_for_deployments_with_stop_action |