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:
authorLin Jen-Shin <godfat@godfat.org>2019-07-08 16:07:21 +0300
committerLin Jen-Shin <godfat@godfat.org>2019-07-08 16:07:21 +0300
commit886521c7e563e04574fd803a22476f1158961fad (patch)
tree642291847190298979eff5e3e4a06ca43039b8d7 /app/models/deployment.rb
parentd14d1340c6d26a132e8db1f9b883aa87276b457c (diff)
parent56c129293578cb620daf1c19b1bc61cd18d9fa83 (diff)
Merge branch '63475-fix-n-1' into 'master'
Reduce N+1 queries in MergeRequestsController#ci_environment_status See merge request gitlab-org/gitlab-ce!30224
Diffstat (limited to 'app/models/deployment.rb')
-rw-r--r--app/models/deployment.rb42
1 files changed, 0 insertions, 42 deletions
diff --git a/app/models/deployment.rb b/app/models/deployment.rb
index a8f5642f726..b69cda4f2f9 100644
--- a/app/models/deployment.rb
+++ b/app/models/deployment.rb
@@ -85,11 +85,6 @@ class Deployment < ApplicationRecord
Commit.truncate_sha(sha)
end
- # Deprecated - will be replaced by a persisted cluster_id
- def deployment_platform_cluster
- environment.deployment_platform&.cluster
- end
-
def execute_hooks
deployment_data = Gitlab::DataBuilder::Deployment.build(self)
project.execute_services(deployment_data, :deployment_hooks)
@@ -176,45 +171,8 @@ class Deployment < ApplicationRecord
deployed_at&.to_time&.in_time_zone&.to_s(:medium)
end
- def has_metrics?
- success? && prometheus_adapter&.can_query?
- end
-
- def metrics
- return {} unless has_metrics?
-
- metrics = prometheus_adapter.query(:deployment, self)
- metrics&.merge(deployment_time: finished_at.to_i) || {}
- end
-
- def additional_metrics
- return {} unless has_metrics?
-
- metrics = prometheus_adapter.query(:additional_metrics_deployment, self)
- metrics&.merge(deployment_time: finished_at.to_i) || {}
- end
-
private
- def prometheus_adapter
- service = project.find_or_initialize_service('prometheus')
-
- if service.can_query?
- service
- else
- cluster_prometheus
- end
- end
-
- # TODO remove fallback case to deployment_platform_cluster.
- # Otherwise we will continue to pay the performance penalty described in
- # https://gitlab.com/gitlab-org/gitlab-ce/issues/63475
- def cluster_prometheus
- cluster_with_fallback = cluster || deployment_platform_cluster
-
- cluster_with_fallback.application_prometheus if cluster_with_fallback&.application_prometheus_available?
- end
-
def ref_path
File.join(environment.ref_path, 'deployments', iid.to_s)
end