From e99a55ffa775179da2868624c4811459f996cb02 Mon Sep 17 00:00:00 2001 From: Thong Kuah Date: Wed, 19 Jun 2019 23:56:47 +1200 Subject: Run least expensive method first If environment is not available, then no point running the more expensive `prometheus_adapter`. --- app/models/environment.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/environment.rb b/app/models/environment.rb index aff20dae09b..09ab8e61a51 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -163,7 +163,7 @@ class Environment < ApplicationRecord end def has_metrics? - prometheus_adapter&.can_query? && available? + available? && prometheus_adapter&.can_query? end def metrics -- cgit v1.2.1 From 65b6a37fa6656fe2956a6a66011a6630545af229 Mon Sep 17 00:00:00 2001 From: Thong Kuah Date: Wed, 19 Jun 2019 23:59:47 +1200 Subject: Run least expensive method first - #has_terminals? available? is much cheaper than deployment_platform --- app/models/environment.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/environment.rb b/app/models/environment.rb index 09ab8e61a51..1f7e8815c8e 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -155,7 +155,7 @@ class Environment < ApplicationRecord end def has_terminals? - deployment_platform.present? && available? && last_deployment.present? + available? && deployment_platform.present? && last_deployment.present? end def terminals -- cgit v1.2.1 From 3129cbd555ef6770eb859614c08cc854ec07175f Mon Sep 17 00:00:00 2001 From: Thong Kuah Date: Thu, 20 Jun 2019 14:25:31 +1200 Subject: Run least expensive method first - has_metrics? Success is relatively cheap compared to prometheus_adapter which can invoke deployment_platform which does a lot of work --- app/models/deployment.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/deployment.rb b/app/models/deployment.rb index 92c7311014a..ee6e830d3ec 100644 --- a/app/models/deployment.rb +++ b/app/models/deployment.rb @@ -179,7 +179,7 @@ class Deployment < ApplicationRecord end def has_metrics? - prometheus_adapter&.can_query? && success? + success? && prometheus_adapter&.can_query? end def metrics -- cgit v1.2.1