Skip to content
Snippets Groups Projects
Commit 54bfc55f authored by Andrew Cimino's avatar Andrew Cimino
Browse files

Delete all CommitStatus for project_id

Move the for_project(ids) scope from Ci::Build to CommitStatus so it
can be reused across both classes.
parent 25f5188e
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -190,8 +190,6 @@ def persisted_environment=(environment)
scope :without_coverage, -> { where(coverage: nil) }
scope :with_coverage_regex, -> { where.not(coverage_regex: nil) }
 
scope :for_project, -> (project_id) { where(project_id: project_id) }
acts_as_taggable
 
add_authentication_token_field :token, encrypted: :required
Loading
Loading
Loading
Loading
@@ -53,6 +53,7 @@ class CommitStatus < Ci::ApplicationRecord
scope :before_stage, -> (index) { where('stage_idx < ?', index) }
scope :for_stage, -> (index) { where(stage_idx: index) }
scope :after_stage, -> (index) { where('stage_idx > ?', index) }
scope :for_project, -> (project_id) { where(project_id: project_id) }
scope :for_ref, -> (ref) { where(ref: ref) }
scope :by_name, -> (name) { where(name: name) }
scope :in_pipelines, ->(pipelines) { where(pipeline: pipelines) }
Loading
Loading
@@ -68,7 +69,8 @@ class CommitStatus < Ci::ApplicationRecord
# 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)
for_project(project_ids)
end
 
scope :with_preloads, -> do
Loading
Loading
Loading
Loading
@@ -150,7 +150,7 @@ def destroy_ci_records!
::Ci::DestroyPipelineService.new(project, current_user).execute(pipeline)
end
 
deleted_count = project.commit_statuses.delete_all
deleted_count = ::CommitStatus.for_project(project).delete_all
 
Gitlab::AppLogger.info(
class: 'Projects::DestroyService',
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment