Class: NewMergeRequestWorker

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

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_CONCURRENCY_LIMIT_PERCENTAGE_BY_URGENCY, WorkerAttributes::DEFAULT_DATA_CONSISTENCY, WorkerAttributes::DEFAULT_DATA_CONSISTENCY_PER_DB, WorkerAttributes::DEFAULT_DEFER_DELAY, WorkerAttributes::LOAD_BALANCED_DATA_CONSISTENCIES, WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_DATA_CONSISTENCIES, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES

Instance Attribute Summary

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 Method Details

#issuable_classObject



36
37
38
# File 'app/workers/new_merge_request_worker.rb', line 36

def issuable_class
  MergeRequest
end

#perform(merge_request_id, user_id) ⇒ Object



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

def perform(merge_request_id, user_id)
  context = { merge_request_id: merge_request_id, user_id: user_id }
  xp = Labkit::UserExperienceSli.resume(:create_merge_request, **context)

  Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab/-/issues/337182')

  xp.error!('merge request not ready') unless objects_found?(merge_request_id, user_id)
  xp.error!('merge request is already prepared') if issuable&.prepared?
  return xp.complete(**context) if xp.has_error?

  MergeRequests::AfterCreateService
    .new(project: issuable.target_project, current_user: user)
    .execute(issuable)

  xp.complete(**context)
end