Skip to content
代码片段 群组 项目
提交 f4ca4171 编辑于 作者: Rutger Wessels's avatar Rutger Wessels
浏览文件

Merge branch '412602-use-looping-instead-of-each_batch' into 'master'

Use loop with delete_all instead of EachBatch

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/138800



Merged-by: default avatarRutger Wessels <rwessels@gitlab.com>
Approved-by: default avatarTyler Amos <tamos@gitlab.com>
Approved-by: default avatarRutger Wessels <rwessels@gitlab.com>
Reviewed-by: default avatarTyler Amos <tamos@gitlab.com>
Co-authored-by: default avatarMichał Zając <mzajac@gitlab.com>
No related branches found
No related tags found
无相关合并请求
...@@ -53,30 +53,31 @@ def perform(project_id) ...@@ -53,30 +53,31 @@ def perform(project_id)
private private
# rubocop:disable Style/SymbolProc -- for some reason, using &:delete_all fails with wrong number of arguments
def drop_by_project_id(project_id) def drop_by_project_id(project_id)
MODELS_TO_DROP_BY_PROJECT_ID.each do |model| MODELS_TO_DROP_BY_PROJECT_ID.each do |model|
model loop do
.by_projects(project_id) deleted = model.by_projects(project_id).limit(BATCH_SIZE).delete_all
.each_batch(of: BATCH_SIZE) { |b| b.delete_all } break if deleted == 0
end
end end
end end
def drop_by_finding_id(finding_ids) def drop_by_finding_id(finding_ids)
MODELS_TO_DROP_BY_FINDING_ID.each do |model| MODELS_TO_DROP_BY_FINDING_ID.each do |model|
model loop do
.by_finding_id(finding_ids) deleted = model.by_finding_id(finding_ids).limit(BATCH_SIZE).delete_all
.each_batch(of: BATCH_SIZE) { |b| b.delete_all } break if deleted == 0
end
end end
end end
def drop_by_vulnerability_id(vulnerability_ids) def drop_by_vulnerability_id(vulnerability_ids)
MODELS_TO_DROP_BY_VULNERABILITY_ID.each do |model| MODELS_TO_DROP_BY_VULNERABILITY_ID.each do |model|
model loop do
.by_vulnerability(vulnerability_ids) deleted = model.by_vulnerability(vulnerability_ids).limit(BATCH_SIZE).delete_all
.each_batch(of: BATCH_SIZE) { |b| b.delete_all } break if deleted == 0
end
end end
end end
# rubocop:enable Style/SymbolProc
end end
end end
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册