debian-mirror-gitlab/app/services/issues/bulk_update_service.rb

25 lines
669 B
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
module Issues
class BulkUpdateService < BaseService
def execute
2015-04-26 12:48:37 +05:30
issues_ids = params.delete(:issues_ids).split(",")
issue_params = params
2014-09-02 18:07:02 +05:30
%i(state_event milestone_id assignee_id add_label_ids remove_label_ids).each do |key|
issue_params.delete(key) unless issue_params[key].present?
end
2014-09-02 18:07:02 +05:30
issues = Issue.where(id: issues_ids)
issues.each do |issue|
2015-09-11 14:41:01 +05:30
next unless can?(current_user, :update_issue, issue)
2015-04-26 12:48:37 +05:30
Issues::UpdateService.new(issue.project, current_user, issue_params).execute(issue)
2014-09-02 18:07:02 +05:30
end
{
2015-04-26 12:48:37 +05:30
count: issues.count,
success: !issues.count.zero?
2014-09-02 18:07:02 +05:30
}
end
end
end