Class: WorkItems::CreateService

Inherits:
Issues::CreateService show all
Includes:
WidgetableService
Defined in:
app/services/work_items/create_service.rb

Direct Known Subclasses

DataSync::BaseCreateService

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

Attributes included from Issues::ResolveDiscussions

#discussion_to_resolve_id, #merge_request_to_resolve_discussions_of_iid

Attributes inherited from BaseContainerService

#container, #current_user, #group, #params, #project

Instance Method Summary collapse

Methods included from WidgetableService

#handle_quick_actions, #initialize_callbacks!

Methods inherited from Issues::CreateService

#after_create, #before_create, #external_author, #handle_assignee_changes, #handle_changes, #resolve_discussions_with_issue

Methods included from Services::ReturnServiceResponses

#error, #success

Methods included from Issues::ResolveDiscussions

#discussions_to_resolve, #filter_resolve_discussion_params, #merge_request_to_resolve_discussions_of

Methods included from RateLimitedService

#execute_without_rate_limiting

Methods inherited from Issues::BaseService

#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

#create_issue_type_allowed?

Methods included from IncidentManagement::UsageData

#track_incident_action

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, #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

#can?, #can_all?, #can_any?

Constructor Details

#initialize(container:, perform_spam_check: true, current_user: nil, params: {}, widget_params: {}) ⇒ CreateService

Returns a new instance of CreateService.



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

def initialize(container:, perform_spam_check: true, current_user: nil, params: {}, widget_params: {})
  super(
    container: container,
    current_user: current_user,
    params: params,
    perform_spam_check: perform_spam_check,
    build_service: ::WorkItems::BuildService.new(container: container, current_user: current_user, params: params)
  )
  @widget_params = widget_params
end

Instance Method Details

#execute(skip_system_notes: false) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/services/work_items/create_service.rb', line 18

def execute(skip_system_notes: false)
  result = skip_system_notes? ? super(skip_system_notes: true) : super
  return result if result.error?

  work_item = result[:issue]

  if work_item.valid?
    publish_event(work_item)
    success(payload(work_item))
  else
    error(work_item.errors.full_messages, :unprocessable_entity, pass_back: payload(work_item))
  end
rescue ::Issuable::Callbacks::Base::Error => e
  error(e.message, :unprocessable_entity)
end

#parentObject



34
35
36
# File 'app/services/work_items/create_service.rb', line 34

def parent
  container
end