diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 13:18:24 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 13:18:24 +0000 |
commit | 0653e08efd039a5905f3fa4f6e9cef9f5d2f799c (patch) | |
tree | 4dcc884cf6d81db44adae4aa99f8ec1233a41f55 /app/models/issue.rb | |
parent | 744144d28e3e7fddc117924fef88de5d9674fe4c (diff) | |
download | gitlab-ce-0653e08efd039a5905f3fa4f6e9cef9f5d2f799c.tar.gz |
Add latest changes from gitlab-org/gitlab@14-3-stable-eev14.3.0-rc42
Diffstat (limited to 'app/models/issue.rb')
-rw-r--r-- | app/models/issue.rb | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb index 48e3fdd51e9..e0b0c352c22 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -128,13 +128,15 @@ class Issue < ApplicationRecord } scope :with_issue_type, ->(types) { where(issue_type: types) } - scope :public_only, -> { where(confidential: false) } + scope :public_only, -> { + without_hidden.where(confidential: false) + } + scope :confidential_only, -> { where(confidential: true) } scope :without_hidden, -> { if Feature.enabled?(:ban_user_feature_flag) - where(id: joins('LEFT JOIN banned_users ON banned_users.user_id = issues.author_id WHERE banned_users.user_id IS NULL') - .select('issues.id')) + where('NOT EXISTS (?)', Users::BannedUser.select(1).where('issues.author_id = banned_users.user_id')) else all end @@ -323,6 +325,13 @@ class Issue < ApplicationRecord ) end + def self.column_order_id_asc + Gitlab::Pagination::Keyset::ColumnOrderDefinition.new( + attribute_name: 'id', + order_expression: arel_table[:id].asc + ) + end + def self.to_branch_name(*args) branch_name = args.map(&:to_s).each_with_index.map do |arg, i| arg.parameterize(preserve_case: i == 0).presence @@ -584,15 +593,9 @@ class Issue < ApplicationRecord confidential_changed?(from: true, to: false) end - # Ensure that the metrics association is safely created and respecting the unique constraint on issue_id override :ensure_metrics def ensure_metrics - if !association(:metrics).loaded? || metrics.blank? - metrics_record = Issue::Metrics.safe_find_or_create_by(issue: self) - self.metrics = metrics_record - end - - metrics.record! + Issue::Metrics.record!(self) end def record_create_action |