Class: MergeRequests::HandleAssigneesChangeService

Inherits:
BaseService show all
Defined in:
app/services/merge_requests/handle_assignees_change_service.rb

Instance Attribute Summary

Attributes inherited from BaseProjectService

#project

Attributes inherited from BaseContainerService

#container, #current_user, #params

Instance Method Summary collapse

Methods inherited from BaseService

#cancel_review_app_jobs!, #cleanup_environments, #create_note, #execute_external_hooks, #execute_hooks, #handle_assignees_change, #handle_changes, #handle_reviewers_change, #hook_data, #inspect, #merge_request_activity_counter, #source_project, #target_project

Methods included from Gitlab::Utils::Override

#extended, extensions, #included, #method_added, #override, #prepended, #queue_verification, verify!

Methods included from AssignsMergeParams

#assign_allowed_merge_params, included

Methods inherited from BaseProjectService

#initialize

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Methods inherited from BaseContainerService

#group_container?, #initialize, #namespace_container?, #project_container?

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

#async_execute(merge_request, old_assignees, options = {}) ⇒ Object


5
6
7
8
9
10
11
12
13
# File 'app/services/merge_requests/handle_assignees_change_service.rb', line 5

def async_execute(merge_request, old_assignees, options = {})
  MergeRequests::HandleAssigneesChangeWorker
    .perform_async(
      merge_request.id,
      current_user.id,
      old_assignees.map(&:id),
      options.stringify_keys # see: https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/1090
    )
end

#execute(merge_request, old_assignees, options = {}) ⇒ Object


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/services/merge_requests/handle_assignees_change_service.rb', line 15

def execute(merge_request, old_assignees, options = {})
  create_assignee_note(merge_request, old_assignees)
  notification_service.async.reassigned_merge_request(merge_request, current_user, old_assignees.to_a)
  todo_service.reassigned_assignable(merge_request, current_user, old_assignees)

  new_assignees = merge_request.assignees - old_assignees
  merge_request_activity_counter.track_users_assigned_to_mr(users: new_assignees)
  merge_request_activity_counter.track_assignees_changed_action(user: current_user)

  execute_assignees_hooks(merge_request, old_assignees) if options[:execute_hooks]

  unless new_assignees.include?(current_user)
    remove_attention_requested(merge_request)
  end
end