summaryrefslogtreecommitdiff
path: root/app/services/groups
diff options
context:
space:
mode:
authordixpac <dino.onex@gmail.com>2016-08-13 14:45:31 +0200
committerdixpac <dino.onex@gmail.com>2017-02-08 09:16:43 +0100
commit0dacf3c169a85e6f3a1c70f3f5e377d47f770d19 (patch)
tree9a7ceb14b6a7aa96636a4024df06fa37c782a3ee /app/services/groups
parenta965edb89d3c260394ffc987832a469e7740415d (diff)
downloadgitlab-ce-0dacf3c169a85e6f3a1c70f3f5e377d47f770d19.tar.gz
Fix inconsistent naming for services that delete things
* Changed name of delete_user_service and worker to destroy * Move and change delete_group_service to Groups::DestroyService * Rename Notes::DeleteService to Notes::DestroyService
Diffstat (limited to 'app/services/groups')
-rw-r--r--app/services/groups/destroy_service.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/app/services/groups/destroy_service.rb b/app/services/groups/destroy_service.rb
new file mode 100644
index 00000000000..7f2d28086f5
--- /dev/null
+++ b/app/services/groups/destroy_service.rb
@@ -0,0 +1,25 @@
+module Groups
+ class DestroyService < Groups::BaseService
+ def async_execute
+ # Soft delete via paranoia gem
+ group.destroy
+ job_id = GroupDestroyWorker.perform_async(group.id, current_user.id)
+ Rails.logger.info("User #{current_user.id} scheduled a deletion of group ID #{group.id} with job ID #{job_id}")
+ end
+
+ def execute
+ group.projects.each do |project|
+ # Execute the destruction of the models immediately to ensure atomic cleanup.
+ # Skip repository removal because we remove directory with namespace
+ # that contain all these repositories
+ ::Projects::DestroyService.new(project, current_user, skip_repo: true).execute
+ end
+
+ group.children.each do |group|
+ DestroyService.new(group, current_user).async_execute
+ end
+
+ group.really_destroy!
+ end
+ end
+end