diff options
author | Jarka Kadlecová <jarka@gitlab.com> | 2018-01-10 10:29:58 +0300 |
---|---|---|
committer | Jarka Kadlecová <jarka@gitlab.com> | 2018-01-12 18:20:38 +0300 |
commit | dcc1ab979a9acdb94aa33a46c262ca21cc8055a9 (patch) | |
tree | e5a51bd9504903705b5f2b0c8eb86928a49aceee /app/services/labels | |
parent | 3576d59ae95a61dd20e997a619dbc6c8e8a70276 (diff) |
Keep subscribers when promoting labels to group labels
Diffstat (limited to 'app/services/labels')
-rw-r--r-- | app/services/labels/promote_service.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/app/services/labels/promote_service.rb b/app/services/labels/promote_service.rb index 997d247be46..74a85e5c9f0 100644 --- a/app/services/labels/promote_service.rb +++ b/app/services/labels/promote_service.rb @@ -13,6 +13,7 @@ module Labels update_issuables(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) end @@ -26,6 +27,15 @@ module Labels private + def subscribe_users(new_label, label_ids) + # users can be subscribed to multiple labels that will be merged into the group one + # we want to keep only one subscription / user + ids_to_update = Subscription.where(subscribable_id: label_ids, subscribable_type: 'Label') + .group(:user_id) + .pluck('MAX(id)') + Subscription.where(id: ids_to_update).update_all(subscribable_id: new_label.id) + end + def label_ids_for_merge(new_label) LabelsFinder .new(current_user, title: new_label.title, group_id: project.group.id) @@ -53,7 +63,7 @@ module Labels end def update_project_labels(label_ids) - Label.where(id: label_ids).delete_all + Label.where(id: label_ids).destroy_all end def clone_label_to_group_label(label) |