Class: WorkItems::DataSync::Widgets::Base

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

Constant Summary collapse

BATCH_SIZE =
100

Constants inherited from Issuable::Callbacks::Base

Issuable::Callbacks::Base::Error

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Callbacks::Base

#log_error, #raise_error

Methods inherited from Issuable::Callbacks::Base

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

Methods included from Gitlab::Allowable

#can?, #can_all?, #can_any?

Constructor Details

#initialize(work_item:, target_work_item:, current_user:, params: {}) ⇒ Base

Returns a new instance of Base.



15
16
17
18
19
20
# File 'app/services/work_items/data_sync/widgets/base.rb', line 15

def initialize(work_item:, target_work_item:, current_user:, params: {})
  @work_item = work_item
  @target_work_item = target_work_item
  @current_user = current_user
  @params = params
end

Instance Attribute Details

#current_userObject (readonly)

Returns the value of attribute current_user.



7
8
9
# File 'app/services/work_items/data_sync/widgets/base.rb', line 7

def current_user
  @current_user
end

#target_work_itemObject (readonly)

Returns the value of attribute target_work_item.



7
8
9
# File 'app/services/work_items/data_sync/widgets/base.rb', line 7

def target_work_item
  @target_work_item
end

#work_itemObject (readonly)

Returns the value of attribute work_item.



7
8
9
# File 'app/services/work_items/data_sync/widgets/base.rb', line 7

def work_item
  @work_item
end

Class Method Details

.cleanup_source_work_item_data?(work_item) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'app/services/work_items/data_sync/widgets/base.rb', line 11

def self.cleanup_source_work_item_data?(work_item)
  Feature.enabled?(:cleanup_data_source_work_item_data, work_item.resource_parent)
end

Instance Method Details

#post_move_cleanupObject

IMPORTANT: This is a callback that is called by BaseCleanupDataService from DataSync::MoveService after the work item is moved to the target namespace to delete the original work item data. That is because we have to implement MoveService as copy to destination & delete from source.

Has to be implemented in the specific widget class or it can be an empty implementation if it does not need to cleanup any data on the original work item



32
# File 'app/services/work_items/data_sync/widgets/base.rb', line 32

def post_move_cleanup; end

#raise_error!(message) ⇒ Object



22
23
24
# File 'app/services/work_items/data_sync/widgets/base.rb', line 22

def raise_error!(message)
  raise ::WorkItems::DataSync::Error, message
end