Class: Issues::CreateService

Inherits:
BaseService show all
Includes:
ResolveDiscussions, SpamCheckMethods
Defined in:
app/services/issues/create_service.rb

Constant Summary

Constants inherited from BaseService

BaseService::NO_REBALANCING_NEEDED

Constants included from Gitlab::Utils::UsageData

Gitlab::Utils::UsageData::FALLBACK

Instance Attribute Summary

Attributes included from ResolveDiscussions

#discussion_to_resolve_id, #merge_request_to_resolve_discussions_of_iid

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods included from ResolveDiscussions

#discussions_to_resolve, #filter_resolve_discussion_params, #merge_request_to_resolve_discussions_of

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Methods included from SpamCheckMethods

#filter_spam_check_params, #spam_check

Methods inherited from BaseService

#close_service, #hook_data, #rebalance_if_needed, #reopen_service

Methods included from IncidentManagement::UsageData

#track_event, #track_incident_action

Methods included from Gitlab::Utils::UsageData

#alt_usage_data, #count, #distinct_count, #measure_duration, #redis_usage_data, #track_usage_event, #with_finished_at, #with_prometheus_client

Methods inherited from BaseService

#initialize

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?

Instance Method Details

#after_create(issuable) ⇒ Object


28
29
30
31
32
33
34
35
36
# File 'app/services/issues/create_service.rb', line 28

def after_create(issuable)
  todo_service.new_issue(issuable, current_user)
  user_agent_detail_service.create
  resolve_discussions_with_issue(issuable)
  delete_milestone_total_issue_counter_cache(issuable.milestone)
  track_incident_action(current_user, issuable, :incident_created)

  super
end

#before_create(issue) ⇒ Object


17
18
19
20
21
22
23
24
25
26
# File 'app/services/issues/create_service.rb', line 17

def before_create(issue)
  spam_check(issue, current_user, action: :create)

  # current_user (defined in BaseService) is not available within run_after_commit block
  user = current_user
  issue.run_after_commit do
    NewIssueWorker.perform_async(issue.id, user.id)
    IssuePlacementWorker.perform_async(issue.id)
  end
end

#execute(skip_system_notes: false) ⇒ Object


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

def execute(skip_system_notes: false)
  @issue = BuildService.new(project, current_user, params).execute

  filter_spam_check_params
  filter_resolve_discussion_params

  create(@issue, skip_system_notes: skip_system_notes)
end

#resolve_discussions_with_issue(issue) ⇒ Object


38
39
40
41
42
43
44
# File 'app/services/issues/create_service.rb', line 38

def resolve_discussions_with_issue(issue)
  return if discussions_to_resolve.empty?

  Discussions::ResolveService.new(project, current_user,
                                  one_or_more_discussions: discussions_to_resolve,
                                  follow_up_issue: issue).execute
end