diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-20 15:07:40 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-20 15:07:40 +0300 |
commit | f864f8a7aafa45b0e4c04e4312f89da4b1227c0f (patch) | |
tree | e559b53ae6a7594f28409bab9d38325200b38495 /app | |
parent | 898e2cc1dfa88b4ac39cb4b35011f61b37f57b51 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/models/deployment_metrics.rb | 10 | ||||
-rw-r--r-- | app/models/environment.rb | 8 | ||||
-rw-r--r-- | app/services/notes/create_service.rb | 14 |
3 files changed, 22 insertions, 10 deletions
diff --git a/app/models/deployment_metrics.rb b/app/models/deployment_metrics.rb index 2056c8bc59c..20f0ec3e9b6 100644 --- a/app/models/deployment_metrics.rb +++ b/app/models/deployment_metrics.rb @@ -13,18 +13,18 @@ class DeploymentMetrics end def has_metrics? - deployment.success? && prometheus_adapter&.can_query? + deployment.success? && prometheus_adapter&.configured? end def metrics - return {} unless has_metrics? + return {} unless has_metrics_and_can_query? metrics = prometheus_adapter.query(:deployment, deployment) metrics&.merge(deployment_time: deployment.finished_at.to_i) || {} end def additional_metrics - return {} unless has_metrics? + return {} unless has_metrics_and_can_query? metrics = prometheus_adapter.query(:additional_metrics_deployment, deployment) metrics&.merge(deployment_time: deployment.finished_at.to_i) || {} @@ -47,4 +47,8 @@ class DeploymentMetrics def cluster_prometheus cluster.application_prometheus if cluster&.application_prometheus_available? end + + def has_metrics_and_can_query? + has_metrics? && prometheus_adapter.can_query? + end end diff --git a/app/models/environment.rb b/app/models/environment.rb index 82bf0f9a615..84a72fee77b 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -208,7 +208,7 @@ class Environment < ApplicationRecord end def metrics - prometheus_adapter.query(:environment, self) if has_metrics? && prometheus_adapter.can_query? + prometheus_adapter.query(:environment, self) if has_metrics_and_can_query? end def prometheus_status @@ -216,7 +216,7 @@ class Environment < ApplicationRecord end def additional_metrics(*args) - return unless has_metrics? + return unless has_metrics_and_can_query? prometheus_adapter.query(:additional_metrics_environment, self, *args.map(&:to_f)) end @@ -285,6 +285,10 @@ class Environment < ApplicationRecord private + def has_metrics_and_can_query? + has_metrics? && prometheus_adapter.can_query? + end + def generate_slug self.slug = Gitlab::Slug::Environment.new(name).generate end diff --git a/app/services/notes/create_service.rb b/app/services/notes/create_service.rb index accfdb5b863..50dc98b88e9 100644 --- a/app/services/notes/create_service.rb +++ b/app/services/notes/create_service.rb @@ -4,9 +4,7 @@ module Notes class CreateService < ::Notes::BaseService # rubocop:disable Metrics/CyclomaticComplexity def execute - merge_request_diff_head_sha = params.delete(:merge_request_diff_head_sha) - - note = Notes::BuildService.new(project, current_user, params).execute + note = Notes::BuildService.new(project, current_user, params.except(:merge_request_diff_head_sha)).execute # n+1: https://gitlab.com/gitlab-org/gitlab-foss/issues/37440 note_valid = Gitlab::GitalyClient.allow_n_plus_1_calls do @@ -23,8 +21,7 @@ module Notes quick_actions_service = QuickActionsService.new(project, current_user) if quick_actions_service.supported?(note) - options = { merge_request_diff_head_sha: merge_request_diff_head_sha } - content, update_params, message = quick_actions_service.execute(note, options) + content, update_params, message = quick_actions_service.execute(note, quick_action_options) only_commands = content.empty? @@ -74,6 +71,11 @@ module Notes private + # EE::Notes::CreateService would override this method + def quick_action_options + { merge_request_diff_head_sha: params[:merge_request_diff_head_sha] } + end + def tracking_data_for(note) label = Gitlab.ee? && note.author == User.visual_review_bot ? 'anonymous_visual_review_note' : 'note' @@ -84,3 +86,5 @@ module Notes end end end + +Notes::CreateService.prepend_if_ee('EE::Notes::CreateService') |