Class: WorkItems::DataSync::Widgets::TimeTracking

Inherits:
Base show all
Defined in:
app/services/work_items/data_sync/widgets/time_tracking.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_create, #after_initialize, #after_save, #after_update, #after_update_commit, #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_save_commitObject



13
14
15
16
17
18
19
# File 'app/services/work_items/data_sync/widgets/time_tracking.rb', line 13

def after_save_commit
  return unless params[:operation] == :move
  return unless target_work_item.get_widget(:time_tracking)
  return if work_item.timelogs.empty?

  WorkItems::CopyTimelogsWorker.perform_async(work_item.id, target_work_item.id)
end

#before_createObject



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

def before_create
  return unless target_work_item.get_widget(:time_tracking)

  target_work_item.time_estimate = work_item.time_estimate
end

#post_move_cleanupObject



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

def post_move_cleanup
  work_item.timelogs.each_batch(of: BATCH_SIZE) do |timelogs|
    timelogs.delete_all
  end
end