Class: Issues::BulkUpdateService

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

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods inherited from BaseService

#hook_data

Methods inherited from BaseService

#abilities, #can?, #deny_visibility_level, #event_service, #initialize, #log_info, #notification_service, #repository, #system_hook_service, #todo_service

Methods included from Gitlab::CurrentSettings

#current_application_settings, #fake_application_settings

Constructor Details

This class inherits a constructor from BaseService

Instance Method Details

#executeObject


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/services/issues/bulk_update_service.rb', line 3

def execute
  issues_ids   = params.delete(:issues_ids).split(",")
  issue_params = params

  issue_params.delete(:state_event)   unless issue_params[:state_event].present?
  issue_params.delete(:milestone_id)  unless issue_params[:milestone_id].present?
  issue_params.delete(:assignee_id)   unless issue_params[:assignee_id].present?

  issues = Issue.where(id: issues_ids)
  issues.each do |issue|
    next unless can?(current_user, :update_issue, issue)

    Issues::UpdateService.new(issue.project, current_user, issue_params).execute(issue)
  end

  {
    count:    issues.count,
    success:  !issues.count.zero?
  }
end