diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-28 00:08:47 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-28 00:08:47 +0300 |
commit | e4ea43b2b85ad5f3115f00220601eb719705139a (patch) | |
tree | 1888a43f802e45ebb8dfed59595a790807777c6f /app/models | |
parent | 390582e118752426acf5cb25ec99103d312d891c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/application_setting.rb | 2 | ||||
-rw-r--r-- | app/models/clusters/applications/elastic_stack.rb | 2 | ||||
-rw-r--r-- | app/models/concerns/relative_positioning.rb | 3 | ||||
-rw-r--r-- | app/models/concerns/resolvable_discussion.rb | 2 | ||||
-rw-r--r-- | app/models/project.rb | 7 | ||||
-rw-r--r-- | app/models/uploads/base.rb | 2 |
6 files changed, 12 insertions, 6 deletions
diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index 10d15e84b8d..0bea5d7b399 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -142,7 +142,7 @@ class ApplicationSetting < ApplicationRecord if: :auto_devops_enabled? validates :enabled_git_access_protocol, - inclusion: { in: %w(ssh http), allow_blank: true, allow_nil: true } + inclusion: { in: %w(ssh http), allow_blank: true } validates :domain_blacklist, presence: { message: 'Domain blacklist cannot be empty if Blacklist is enabled.' }, diff --git a/app/models/clusters/applications/elastic_stack.rb b/app/models/clusters/applications/elastic_stack.rb index e86a4597ed8..de7d3ab3fdb 100644 --- a/app/models/clusters/applications/elastic_stack.rb +++ b/app/models/clusters/applications/elastic_stack.rb @@ -16,7 +16,7 @@ module Clusters include ::Gitlab::Utils::StrongMemoize include IgnorableColumns - ignore_column :kibana_hostname, remove_with: '12.8', remove_after: '2020-01-22' + ignore_column :kibana_hostname, remove_with: '12.9', remove_after: '2020-02-22' default_value_for :version, VERSION diff --git a/app/models/concerns/relative_positioning.rb b/app/models/concerns/relative_positioning.rb index b645cf71443..1653ecdb305 100644 --- a/app/models/concerns/relative_positioning.rb +++ b/app/models/concerns/relative_positioning.rb @@ -237,8 +237,7 @@ module RelativePositioning relation .pluck(self.class.relative_positioning_parent_column, Arel.sql("#{calculation}(relative_position) AS position")) - .first&. - last + .first&.last end def scoped_items diff --git a/app/models/concerns/resolvable_discussion.rb b/app/models/concerns/resolvable_discussion.rb index c0490af2453..5d78eea7fca 100644 --- a/app/models/concerns/resolvable_discussion.rb +++ b/app/models/concerns/resolvable_discussion.rb @@ -63,7 +63,7 @@ module ResolvableDiscussion return unless resolved? strong_memoize(:last_resolved_note) do - resolved_notes.sort_by(&:resolved_at).last + resolved_notes.max_by(&:resolved_at) end end diff --git a/app/models/project.rb b/app/models/project.rb index a51dd3c1048..b2de2b32ae0 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -397,6 +397,8 @@ class Project < ApplicationRecord scope :sorted_by_stars_desc, -> { reorder(star_count: :desc) } scope :sorted_by_stars_asc, -> { reorder(star_count: :asc) } scope :sorted_by_name_asc_limited, ->(limit) { reorder(name: :asc).limit(limit) } + # Sometimes queries (e.g. using CTEs) require explicit disambiguation with table name + scope :projects_order_id_desc, -> { reorder("#{table_name}.id DESC") } scope :in_namespace, ->(namespace_ids) { where(namespace_id: namespace_ids) } scope :personal, ->(user) { where(namespace_id: user.namespace_id) } @@ -543,6 +545,11 @@ class Project < ApplicationRecord ) end + def self.wrap_authorized_projects_with_cte(collection) + cte = Gitlab::SQL::CTE.new(:authorized_projects, collection) + Project.with(cte.to_arel).from(cte.alias_to(Project.arel_table)) + end + scope :active, -> { joins(:issues, :notes, :merge_requests).order('issues.created_at, notes.created_at, merge_requests.created_at DESC') } scope :abandoned, -> { where('projects.last_activity_at < ?', 6.months.ago) } diff --git a/app/models/uploads/base.rb b/app/models/uploads/base.rb index 29f376670da..442ed733566 100644 --- a/app/models/uploads/base.rb +++ b/app/models/uploads/base.rb @@ -7,7 +7,7 @@ module Uploads attr_reader :logger def initialize(logger: nil) - @logger ||= Rails.logger # rubocop:disable Gitlab/RailsLogger + @logger = Rails.logger # rubocop:disable Gitlab/RailsLogger end def delete_keys_async(keys_to_delete) |