summaryrefslogtreecommitdiff
path: root/app/services/events
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-01-20 09:16:11 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-01-20 09:16:11 +0000
commitedaa33dee2ff2f7ea3fac488d41558eb5f86d68c (patch)
tree11f143effbfeba52329fb7afbd05e6e2a3790241 /app/services/events
parentd8a5691316400a0f7ec4f83832698f1988eb27c1 (diff)
downloadgitlab-ce-edaa33dee2ff2f7ea3fac488d41558eb5f86d68c.tar.gz
Add latest changes from gitlab-org/gitlab@14-7-stable-eev14.7.0-rc42
Diffstat (limited to 'app/services/events')
-rw-r--r--app/services/events/destroy_service.rb15
1 files changed, 12 insertions, 3 deletions
diff --git a/app/services/events/destroy_service.rb b/app/services/events/destroy_service.rb
index fdb718f0fcb..3a0a7b339bf 100644
--- a/app/services/events/destroy_service.rb
+++ b/app/services/events/destroy_service.rb
@@ -2,20 +2,29 @@
module Events
class DestroyService
+ BATCH_SIZE = 50
+
def initialize(project)
@project = project
end
def execute
- project.events.all.delete_all
+ loop do
+ count = delete_events_in_batches
+ break if count < BATCH_SIZE
+ end
ServiceResponse.success(message: 'Events were deleted.')
- rescue StandardError
- ServiceResponse.error(message: 'Failed to remove events.')
+ rescue StandardError => e
+ ServiceResponse.error(message: e.message)
end
private
attr_reader :project
+
+ def delete_events_in_batches
+ project.events.limit(BATCH_SIZE).delete_all
+ end
end
end