Class: WorkItems::DataSync::BaseCreateService
- Inherits:
-
CreateService
- Object
- BaseContainerService
- IssuableBaseService
- Issues::BaseService
- Issues::CreateService
- CreateService
- WorkItems::DataSync::BaseCreateService
- Defined in:
- app/services/work_items/data_sync/base_create_service.rb
Overview
This is a altered version of the WorkItem::CreateService. This overwrites the ‘initialize_callbacks!` and replaces the callbacks called by `WorkItem::CreateService` to setup data sync related callbacks which are used to copy data from the original work item to the target work item.
Constant Summary
Constants included from RateLimitedService
RateLimitedService::RateLimitedNotSetupError
Constants inherited from Issues::BaseService
Issues::BaseService::EpicAssignmentError, Issues::BaseService::NO_REBALANCING_NEEDED
Constants included from Gitlab::Utils::UsageData
Gitlab::Utils::UsageData::DISTRIBUTED_HLL_FALLBACK, Gitlab::Utils::UsageData::FALLBACK, Gitlab::Utils::UsageData::HISTOGRAM_FALLBACK, Gitlab::Utils::UsageData::MAX_BUCKET_SIZE
Instance Attribute Summary collapse
-
#operation ⇒ Object
readonly
Returns the value of attribute operation.
-
#original_work_item ⇒ Object
readonly
Returns the value of attribute original_work_item.
-
#sync_data_params ⇒ Object
readonly
Returns the value of attribute sync_data_params.
Attributes included from Issues::ResolveDiscussions
#discussion_to_resolve_id, #merge_request_to_resolve_discussions_object, #merge_request_to_resolve_discussions_of_iid
Attributes inherited from BaseContainerService
#container, #current_user, #group, #params, #project
Instance Method Summary collapse
-
#initialize(original_work_item:, operation:, **kwargs) ⇒ BaseCreateService
constructor
A new instance of BaseCreateService.
- #initialize_callbacks!(work_item) ⇒ Object
Methods inherited from CreateService
Methods included from WidgetableService
#handle_quick_actions, #params_include_state_and_status_changes?
Methods inherited from Issues::CreateService
#after_create, #before_create, #execute, #external_author, #handle_assignee_changes, #handle_changes, #publish_event, #resolve_discussions_with_issue
Methods included from Services::ReturnServiceResponses
Methods included from Issues::ResolveDiscussions
#discussions_to_resolve, #filter_resolve_discussion_params, #merge_request_to_resolve_discussions_of
Methods included from RateLimitedService
#execute, #execute_without_rate_limiting
Methods inherited from Issues::BaseService
#available_callbacks, #close_service, #execute_hooks, #hook_data, #rebalance_if_needed, #reopen_service
Methods included from Gitlab::Utils::Override
#extended, extensions, #included, #method_added, #override, #prepended, #queue_verification, verify!
Methods included from Issues::IssueTypeHelpers
Methods included from IncidentManagement::UsageData
Methods included from Gitlab::Utils::UsageData
#add, #add_metric, #alt_usage_data, #average, #count, #distinct_count, #estimate_batch_distinct_count, #histogram, #maximum_id, #measure_duration, #metrics_collection_metadata, #minimum_id, #redis_usage_data, #sum, #track_usage_event, #with_finished_at, #with_metadata, #with_prometheus_client
Methods inherited from BaseContainerService
#group_container?, #namespace_container?, #project_container?, #project_group, #root_ancestor
Methods included from BaseServiceUtility
#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level
Methods included from Gitlab::Allowable
Constructor Details
#initialize(original_work_item:, operation:, **kwargs) ⇒ BaseCreateService
Returns a new instance of BaseCreateService.
11 12 13 14 15 16 |
# File 'app/services/work_items/data_sync/base_create_service.rb', line 11 def initialize(original_work_item:, operation:, **kwargs) super(**kwargs) @original_work_item = original_work_item @operation = operation end |
Instance Attribute Details
#operation ⇒ Object (readonly)
Returns the value of attribute operation.
9 10 11 |
# File 'app/services/work_items/data_sync/base_create_service.rb', line 9 def operation @operation end |
#original_work_item ⇒ Object (readonly)
Returns the value of attribute original_work_item.
9 10 11 |
# File 'app/services/work_items/data_sync/base_create_service.rb', line 9 def original_work_item @original_work_item end |
#sync_data_params ⇒ Object (readonly)
Returns the value of attribute sync_data_params.
9 10 11 |
# File 'app/services/work_items/data_sync/base_create_service.rb', line 9 def sync_data_params @sync_data_params end |
Instance Method Details
#initialize_callbacks!(work_item) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/services/work_items/data_sync/base_create_service.rb', line 18 def initialize_callbacks!(work_item) # reset system notes timestamp work_item. = nil @callbacks = original_work_item..filter_map do || sync_data_callback_class = .class.sync_data_callback_class next if sync_data_callback_class.nil? callback_params = {} if sync_data_callback_class.const_defined?(:ALLOWED_PARAMS) callback_params.merge!(params.extract!(*sync_data_callback_class::ALLOWED_PARAMS)) end sync_data_callback_class.new( work_item: original_work_item, target_work_item: work_item, current_user: current_user, params: callback_params.merge({ operation: operation }) ) end @callbacks += WorkItem..filter_map do |association_name| sync_callback_class = WorkItem.sync_callback_class(association_name) next if sync_callback_class.nil? sync_callback_class.new( work_item: original_work_item, target_work_item: work_item, current_user: current_user, params: { operation: operation } ) end @callbacks end |