diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-25 12:08:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-25 12:08:11 +0300 |
commit | 5064bf8c5647d4c4430cbb4d097cf1592416de29 (patch) | |
tree | d051bf2abe2cc7061b3a7facb6669a56ccb9cf54 /app/models | |
parent | 9c83aadd2604e7e6cb1f84683f951e6b12872618 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/commit_status.rb | 9 | ||||
-rw-r--r-- | app/models/concerns/noteable.rb | 6 | ||||
-rw-r--r-- | app/models/project_services/prometheus_service.rb | 9 | ||||
-rw-r--r-- | app/models/snippet.rb | 2 |
4 files changed, 19 insertions, 7 deletions
diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb index 35b727720ba..03260b28335 100644 --- a/app/models/commit_status.rb +++ b/app/models/commit_status.rb @@ -62,13 +62,16 @@ class CommitStatus < ApplicationRecord preload(project: :namespace) end - scope :match_id_and_lock_version, -> (slice) do + scope :match_id_and_lock_version, -> (items) do # it expects that items are an array of attributes to match # each hash needs to have `id` and `lock_version` - slice.inject(self) do |relation, item| - match = CommitStatus.where(item.slice(:id, :lock_version)) + or_conditions = items.inject(none) do |relation, item| + match = CommitStatus.default_scoped.where(item.slice(:id, :lock_version)) + relation.or(match) end + + merge(or_conditions) end # We use `CommitStatusEnums.failure_reasons` here so that EE can more easily diff --git a/app/models/concerns/noteable.rb b/app/models/concerns/noteable.rb index 19f2daa1b01..a7f1fb66a88 100644 --- a/app/models/concerns/noteable.rb +++ b/app/models/concerns/noteable.rb @@ -79,6 +79,12 @@ module Noteable .discussions(self) end + def discussion_ids_relation + notes.select(:discussion_id) + .group(:discussion_id) + .order('MIN(created_at), MIN(id)') + end + def capped_notes_count(max) notes.limit(max).count end diff --git a/app/models/project_services/prometheus_service.rb b/app/models/project_services/prometheus_service.rb index 75dfad4f3df..fd4ee069041 100644 --- a/app/models/project_services/prometheus_service.rb +++ b/app/models/project_services/prometheus_service.rb @@ -81,7 +81,7 @@ class PrometheusService < MonitoringService def prometheus_client return unless should_return_client? - Gitlab::PrometheusClient.new(api_url) + Gitlab::PrometheusClient.new(api_url, allow_local_requests: allow_local_api_url?) end def prometheus_available? @@ -94,7 +94,8 @@ class PrometheusService < MonitoringService end def allow_local_api_url? - self_monitoring_project? && internal_prometheus_url? + allow_local_requests_from_web_hooks_and_services? || + (self_monitoring_project? && internal_prometheus_url?) end def configured? @@ -111,6 +112,10 @@ class PrometheusService < MonitoringService api_url.present? && api_url == ::Gitlab::Prometheus::Internal.uri end + def allow_local_requests_from_web_hooks_and_services? + current_settings.allow_local_requests_from_web_hooks_and_services? + end + def should_return_client? api_url.present? && manual_configuration? && active? && valid? end diff --git a/app/models/snippet.rb b/app/models/snippet.rb index b6127baca90..c7b5d7c8278 100644 --- a/app/models/snippet.rb +++ b/app/models/snippet.rb @@ -19,8 +19,6 @@ class Snippet < ApplicationRecord MAX_FILE_COUNT = 1 - ignore_column :repository_storage, remove_with: '12.10', remove_after: '2020-03-22' - cache_markdown_field :title, pipeline: :single_line cache_markdown_field :description cache_markdown_field :content |