Class: WorkItems::DataSync::Widgets::Assignees

Inherits:
Base show all
Defined in:
app/services/work_items/data_sync/widgets/assignees.rb

Constant Summary

Constants inherited from Base

Base::BATCH_SIZE

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

#log_error, #raise_error

Methods inherited from Issuable::Callbacks::Base

#after_initialize, #after_save, #after_save_commit, #after_update, #after_update_commit, #before_create, #before_update, execute_without_params?, #initialize

Methods included from Gitlab::Allowable

#can?, #can_all?, #can_any?

Constructor Details

This class inherits a constructor from WorkItems::DataSync::Widgets::Base

Instance Method Details

#after_createObject



7
8
9
10
11
12
13
14
15
# File 'app/services/work_items/data_sync/widgets/assignees.rb', line 7

def after_create
  return unless target_work_item.get_widget(:assignees)

  work_item.issue_assignees.each_batch(column: :user_id, of: BATCH_SIZE) do |assignees_batch|
    ::IssueAssignee.insert_all(
      new_work_item_assignees(assignees_batch.map(&:user_id)), unique_by: [:issue_id, :user_id]
    )
  end
end

#post_move_cleanupObject



17
18
19
20
21
# File 'app/services/work_items/data_sync/widgets/assignees.rb', line 17

def post_move_cleanup
  work_item.issue_assignees.each_batch(column: :user_id, of: BATCH_SIZE) do |assignees_batch|
    assignees_batch.delete_all
  end
end