summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-08-23 18:11:07 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-08-23 18:11:07 +0000
commit5e9fe672fa0eda6322bd392e8502d1886804bd07 (patch)
treee2dbccd4f9b92ead855d87ff4fcffaff4fe9fb72 /app/models
parenta7f478c9b1806a67ec9d991c3f54c242bb596f60 (diff)
downloadgitlab-ce-5e9fe672fa0eda6322bd392e8502d1886804bd07.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models')
-rw-r--r--app/models/application_record.rb6
-rw-r--r--app/models/application_setting.rb2
-rw-r--r--app/models/internal_id.rb4
-rw-r--r--app/models/packages/package.rb2
4 files changed, 8 insertions, 6 deletions
diff --git a/app/models/application_record.rb b/app/models/application_record.rb
index 29ef76547e0..2353a514097 100644
--- a/app/models/application_record.rb
+++ b/app/models/application_record.rb
@@ -31,7 +31,7 @@ class ApplicationRecord < ActiveRecord::Base
end
def self.safe_ensure_unique(retries: 0)
- transaction(requires_new: true) do
+ transaction(requires_new: true) do # rubocop:disable Performance/ActiveRecordSubtransactions
yield
end
rescue ActiveRecord::RecordNotUnique
@@ -55,7 +55,7 @@ class ApplicationRecord < ActiveRecord::Base
# currently one third of the default 15-second timeout
def self.with_fast_read_statement_timeout(timeout_ms = 5000)
::Gitlab::Database::LoadBalancing::Session.current.fallback_to_replicas_for_ambiguous_queries do
- transaction(requires_new: true) do
+ transaction(requires_new: true) do # rubocop:disable Performance/ActiveRecordSubtransactions
connection.exec_query("SET LOCAL statement_timeout = #{timeout_ms}")
yield
@@ -80,7 +80,7 @@ class ApplicationRecord < ActiveRecord::Base
#
# When calling this method on an association, just calling `self.create` would call `ActiveRecord::Persistence.create`
# and that skips some code that adds the newly created record to the association.
- transaction(requires_new: true) { all.create(*args, &block) }
+ transaction(requires_new: true) { all.create(*args, &block) } # rubocop:disable Performance/ActiveRecordSubtransactions
rescue ActiveRecord::RecordNotUnique
find_by(*args)
end
diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb
index c4b6bcb9395..8ed408d2c23 100644
--- a/app/models/application_setting.rb
+++ b/app/models/application_setting.rb
@@ -622,7 +622,7 @@ class ApplicationSetting < ApplicationRecord
def self.create_from_defaults
check_schema!
- transaction(requires_new: true) do
+ transaction(requires_new: true) do # rubocop:disable Performance/ActiveRecordSubtransactions
super
end
rescue ActiveRecord::RecordNotUnique
diff --git a/app/models/internal_id.rb b/app/models/internal_id.rb
index 107b1914af4..9cbb5f92bbd 100644
--- a/app/models/internal_id.rb
+++ b/app/models/internal_id.rb
@@ -239,7 +239,7 @@ class InternalId < ApplicationRecord
lookup
else
begin
- subject.transaction(requires_new: true) do
+ subject.transaction(requires_new: true) do # rubocop:disable Performance/ActiveRecordSubtransactions
InternalId.create!(
**scope,
usage: usage_value,
@@ -362,7 +362,7 @@ class InternalId < ApplicationRecord
value
else
begin
- subject.transaction(requires_new: true) do
+ subject.transaction(requires_new: true) do # rubocop:disable Performance/ActiveRecordSubtransactions
internal_id = InternalId.create!(**scope, usage: usage, last_value: value)
internal_id.last_value
end
diff --git a/app/models/packages/package.rb b/app/models/packages/package.rb
index 4ea127fc222..dcc3970c49f 100644
--- a/app/models/packages/package.rb
+++ b/app/models/packages/package.rb
@@ -1,5 +1,6 @@
# frozen_string_literal: true
class Packages::Package < ApplicationRecord
+ include EachBatch
include Sortable
include Gitlab::SQL::Pattern
include UsageStatistics
@@ -104,6 +105,7 @@ class Packages::Package < ApplicationRecord
scope :including_build_info, -> { includes(pipelines: :user) }
scope :including_project_route, -> { includes(project: { namespace: :route }) }
scope :including_tags, -> { includes(:tags) }
+ scope :including_dependency_links, -> { includes(dependency_links: :dependency) }
scope :with_conan_channel, ->(package_channel) do
joins(:conan_metadatum).where(packages_conan_metadata: { package_channel: package_channel })