Class: NewIssueWorker

Inherits:
Object
  • Object
show all
Includes:
ApplicationWorker, NewIssuable
Defined in:
app/workers/new_issue_worker.rb

Overview

rubocop:disable Scalability/IdempotentWorker

Constant Summary

Constants included from ApplicationWorker

ApplicationWorker::LOGGING_EXTRA_KEY, ApplicationWorker::SAFE_PUSH_BULK_LIMIT

Constants included from Gitlab::Loggable

Gitlab::Loggable::ANONYMOUS

Constants included from WorkerAttributes

WorkerAttributes::DEFAULT_DATA_CONSISTENCY, WorkerAttributes::DEFAULT_DEFER_DELAY, WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_DATA_CONSISTENCIES, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES

Instance Attribute Summary collapse

Attributes included from NewIssuable

#issuable, #user

Instance Method Summary collapse

Methods included from NewIssuable

#log_error, #objects_found?, #set_issuable, #set_user

Methods included from Gitlab::Loggable

#build_structured_payload

Methods included from Gitlab::SidekiqVersioning::Worker

#job_version

Methods included from WorkerContext

#with_context

Instance Attribute Details

#issuable_classObject (readonly)

Returns the value of attribute issuable_class.



16
17
18
# File 'app/workers/new_issue_worker.rb', line 16

def issuable_class
  @issuable_class
end

Instance Method Details

#perform(issue_id, user_id, issuable_class = 'Issue') ⇒ Object



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

def perform(issue_id, user_id, issuable_class = 'Issue')
  @issuable_class = issuable_class.constantize

  return unless objects_found?(issue_id, user_id)

  ::EventCreateService.new.open_issue(issuable, user)
  ::NotificationService.new.new_issue(issuable, user)

  issuable.create_cross_references!(user)

  Issues::AfterCreateService
    .new(container: issuable.project, current_user: user)
    .execute(issuable)

  log_audit_event if user.project_bot?
end