summaryrefslogtreecommitdiff
path: root/app/services/labels
diff options
context:
space:
mode:
Diffstat (limited to 'app/services/labels')
-rw-r--r--app/services/labels/promote_service.rb21
1 files changed, 13 insertions, 8 deletions
diff --git a/app/services/labels/promote_service.rb b/app/services/labels/promote_service.rb
index e73e6476c12..cc91fd4b4d2 100644
--- a/app/services/labels/promote_service.rb
+++ b/app/services/labels/promote_service.rb
@@ -13,13 +13,8 @@ module Labels
new_label = clone_label_to_group_label(label)
label_ids_for_merge(new_label).find_in_batches(batch_size: BATCH_SIZE) do |batched_ids|
- update_issuables(new_label, batched_ids)
- update_resource_label_events(new_label, batched_ids)
- update_issue_board_lists(new_label, batched_ids)
- update_priorities(new_label, batched_ids)
- subscribe_users(new_label, batched_ids)
- # Order is important, project labels need to be last
- update_project_labels(batched_ids)
+ update_old_label_relations(new_label, batched_ids)
+ destroy_project_labels(batched_ids)
end
# We skipped validations during creation. Let's run them now, after deleting conflicting labels
@@ -32,6 +27,14 @@ module Labels
private
+ def update_old_label_relations(new_label, old_label_ids)
+ update_issuables(new_label, old_label_ids)
+ update_resource_label_events(new_label, old_label_ids)
+ update_issue_board_lists(new_label, old_label_ids)
+ update_priorities(new_label, old_label_ids)
+ subscribe_users(new_label, old_label_ids)
+ end
+
# rubocop: disable CodeReuse/ActiveRecord
def subscribe_users(new_label, label_ids)
# users can be subscribed to multiple labels that will be merged into the group one
@@ -86,7 +89,7 @@ module Labels
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
- def update_project_labels(label_ids)
+ def destroy_project_labels(label_ids)
Label.where(id: label_ids).destroy_all # rubocop: disable DestroyAll
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -105,3 +108,5 @@ module Labels
end
end
end
+
+Labels::PromoteService.prepend_if_ee('EE::Labels::PromoteService')