Class: WorkItems::DataSync::Widgets::Notifications
- Inherits:
-
Base
- Object
- Issuable::Callbacks::Base
- Callbacks::Base
- Base
- WorkItems::DataSync::Widgets::Notifications
- Defined in:
- app/services/work_items/data_sync/widgets/notifications.rb
Constant Summary
Constants inherited from Base
Constants inherited from Issuable::Callbacks::Base
Issuable::Callbacks::Base::Error
Instance Attribute Summary
Attributes inherited from Base
#current_user, #target_work_item, #work_item
Instance Method Summary collapse
Methods inherited from Base
cleanup_source_work_item_data?, #initialize, #raise_error!
Methods inherited from Callbacks::Base
Methods inherited from Issuable::Callbacks::Base
#after_create, #after_initialize, #after_save, #after_update, #after_update_commit, #before_create, #before_update, execute_without_params?, #initialize
Methods included from Gitlab::Allowable
Constructor Details
This class inherits a constructor from WorkItems::DataSync::Widgets::Base
Instance Method Details
#after_save_commit ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/services/work_items/data_sync/widgets/notifications.rb', line 7 def after_save_commit return unless target_work_item.(:notifications) notify_participants return unless params[:operation] == :move work_item.subscriptions.each_batch(of: BATCH_SIZE) do |subscriptions_batch| ::Subscription.insert_all(new_work_item_subscriptions(subscriptions_batch)) end # This replicates current move Issues::MoveService behaviour. This should be changed though to # move sent_notifications for any work_item that is being moved. return unless work_item.from_service_desk? # When moving sent notifications for any work item this can entail updating many records in some instances. # We should consider moving this to an async worker rather than have it run in a single request. work_item.sent_notifications.each_batch(column: :id, of: BATCH_SIZE) do |sent_notifications_batch| new_sent_notifications = new_work_item_sent_notifications(sent_notifications_batch) ::SentNotification.transaction do sent_notifications_batch.delete_all ::SentNotification.insert_all(new_sent_notifications) end end end |
#post_move_cleanup ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/services/work_items/data_sync/widgets/notifications.rb', line 35 def post_move_cleanup work_item.subscriptions.each_batch(of: BATCH_SIZE) do |subscriptions_batch| ::Subscription.id_in(subscriptions_batch.select(:id)).delete_all end # Until we implement async copy of sent_notifications, we'll continue to copy only # notifications for service_desk items. So only service_desk items can be skipped here as they were already # deleted in the transaction above return if work_item.from_service_desk? # When moving sent notifications for any work item this can entail deleting many records in some instances. # We should consider moving this to an async worker rather than have it run in a single request. work_item.sent_notifications.each_batch(column: :id, of: BATCH_SIZE) do |sent_notifications_batch| sent_notifications_batch.delete_all end end |