bulk_update_service.rb 756 Bytes
Newer Older
1
module Issues
2
  class BulkUpdateService < BaseService
3
    def execute
4 5
      issues_ids   = params.delete(:issues_ids).split(",")
      issue_params = params
6

7 8 9
      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?
10

Jeroen van Baarsen's avatar
Jeroen van Baarsen committed
11
      issues = Issue.where(id: issues_ids)
12
      issues.each do |issue|
13
        next unless can?(current_user, :update_issue, issue)
14 15

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

      {
19 20
        count:    issues.count,
        success:  !issues.count.zero?
21 22 23 24
      }
    end
  end
end