gitlab-org--gitlab-foss/app/services/issues/bulk_update_service.rb

26 lines
689 B
Ruby
Raw Normal View History

2013-05-14 07:34:34 -04:00
module Issues
class BulkUpdateService < BaseService
2013-05-14 07:34:34 -04:00
def execute
issues_ids = params.delete(:issues_ids).split(",")
issue_params = params
2013-05-14 07:34:34 -04:00
%i(state_event milestone_id assignee_id add_label_ids remove_label_ids subscription_event).each do |key|
issue_params.delete(key) unless issue_params[key].present?
end
2013-05-14 07:34:34 -04:00
issues = Issue.where(id: issues_ids)
2013-05-14 07:34:34 -04:00
issues.each do |issue|
next unless can?(current_user, :update_issue, issue)
Issues::UpdateService.new(issue.project, current_user, issue_params).execute(issue)
2013-05-14 07:34:34 -04:00
end
{
count: issues.count,
success: !issues.count.zero?
2013-05-14 07:34:34 -04:00
}
end
end
end