Commit 0ab64ac7 authored by Shinya Maeda's avatar Shinya Maeda

Fix app/models/environment.rb

parent b59ff4fe
...@@ -137,16 +137,20 @@ class Environment < ActiveRecord::Base ...@@ -137,16 +137,20 @@ class Environment < ActiveRecord::Base
end end
end end
def deployment_platform
project.deployment_platform(environment: self)
end
def has_terminals? def has_terminals?
project.deployment_platform(environment: name).present? && available? && last_deployment.present? deployment_platform.present? && available? && last_deployment.present?
end end
def terminals def terminals
project.deployment_platform(environment: name).terminals(self) if has_terminals? deployment_platform.terminals(self) if has_terminals?
end end
def rollout_status def rollout_status
project.deployment_platform.rollout_status(self) if has_terminals? deployment_platform.rollout_status(self) if has_terminals?
end end
def has_metrics? def has_metrics?
......
...@@ -905,7 +905,7 @@ class Project < ActiveRecord::Base ...@@ -905,7 +905,7 @@ class Project < ActiveRecord::Base
@ci_service ||= ci_services.reorder(nil).find_by(active: true) @ci_service ||= ci_services.reorder(nil).find_by(active: true)
end end
def deployment_platform def deployment_platform(environment: nil)
@deployment_platform ||= clusters.where(environment_scope: '*').find_by(enabled: true)&.platform_kubernetes @deployment_platform ||= clusters.where(environment_scope: '*').find_by(enabled: true)&.platform_kubernetes
@deployment_platform ||= services.where(category: :deployment).reorder(nil).find_by(active: true) @deployment_platform ||= services.where(category: :deployment).reorder(nil).find_by(active: true)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment