Class: Boards::Issues::MoveService

Inherits:
BaseService show all
Defined in:
app/services/boards/issues/move_service.rb

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #parent

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

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?

Constructor Details

This class inherits a constructor from Boards::BaseService

Instance Method Details

#execute(issue) ⇒ Object


6
7
8
9
10
11
# File 'app/services/boards/issues/move_service.rb', line 6

def execute(issue)
  issue_modification_params = issue_params(issue)
  return false if issue_modification_params.empty?

  move_single_issue(issue, issue_modification_params)
end

#execute_multiple(issues) ⇒ Object


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/services/boards/issues/move_service.rb', line 13

def execute_multiple(issues)
  return execute_multiple_empty_result if issues.empty?

  handled_issues = []
  last_inserted_issue_id = nil
  count = issues.each.inject(0) do |moved_count, issue|
    issue_modification_params = issue_params(issue)
    next moved_count if issue_modification_params.empty?

    if last_inserted_issue_id
      issue_modification_params[:move_between_ids] = move_below(last_inserted_issue_id)
    end

    last_inserted_issue_id = issue.id
    handled_issue = move_single_issue(issue, issue_modification_params)
    handled_issues << present_issue_entity(handled_issue) if handled_issue
    handled_issue && handled_issue.valid? ? moved_count + 1 : moved_count
  end

  {
    count: count,
    success: count == issues.size,
    issues: handled_issues
  }
end