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/commit_status.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/commit_status.rb')
-rw-r--r-- | app/models/commit_status.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb index b34d64de101..8cba3d04502 100644 --- a/app/models/commit_status.rb +++ b/app/models/commit_status.rb @@ -56,15 +56,19 @@ class CommitStatus < Ci::ApplicationRecord scope :for_ref, -> (ref) { where(ref: ref) } scope :by_name, -> (name) { where(name: name) } scope :in_pipelines, ->(pipelines) { where(pipeline: pipelines) } - scope :eager_load_pipeline, -> { eager_load(:pipeline, project: { namespace: :route }) } scope :with_pipeline, -> { joins(:pipeline) } - scope :updated_at_before, ->(date) { where('updated_at < ?', date) } + scope :updated_at_before, ->(date) { where('ci_builds.updated_at < ?', date) } + scope :created_at_before, ->(date) { where('ci_builds.created_at < ?', date) } scope :updated_before, ->(lookback:, timeout:) { where('(ci_builds.created_at BETWEEN ? AND ?) AND (ci_builds.updated_at BETWEEN ? AND ?)', lookback, timeout, lookback, timeout) } + # The scope applies `pluck` to split the queries. Use with care. scope :for_project_paths, -> (paths) do - where(project: Project.where_full_path_in(Array(paths))) + # Pluck is used to split this query. Splitting the query is required for database decomposition for `ci_*` tables. + # https://docs.gitlab.com/ee/development/database/transaction_guidelines.html#database-decomposition-and-sharding + project_ids = Project.where_full_path_in(Array(paths)).pluck(:id) + where(project: project_ids) end scope :with_preloads, -> do |