Class: Issuable::BulkUpdateService

Inherits:
Object
  • Object
show all
Includes:
Gitlab::Allowable
Defined in:
app/services/issuable/bulk_update_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Gitlab::Allowable

#can?

Constructor Details

#initialize(parent, user = nil, params = {}) ⇒ BulkUpdateService

Returns a new instance of BulkUpdateService.


9
10
11
12
13
# File 'app/services/issuable/bulk_update_service.rb', line 9

def initialize(parent, user = nil, params = {})
  @parent = parent
  @current_user = user
  @params = params.dup
end

Instance Attribute Details

#current_userObject

Returns the value of attribute current_user.


7
8
9
# File 'app/services/issuable/bulk_update_service.rb', line 7

def current_user
  @current_user
end

#paramsObject

Returns the value of attribute params.


7
8
9
# File 'app/services/issuable/bulk_update_service.rb', line 7

def params
  @params
end

#parentObject

Returns the value of attribute parent.


7
8
9
# File 'app/services/issuable/bulk_update_service.rb', line 7

def parent
  @parent
end

Instance Method Details

#execute(type) ⇒ Object


15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/services/issuable/bulk_update_service.rb', line 15

def execute(type)
  ids = params.delete(:issuable_ids).split(",")
  set_update_params(type)
  updated_issuables = update_issuables(type, ids)

  if updated_issuables.present? && requires_count_cache_reset?(type)
    schedule_group_issues_count_reset(updated_issuables)
  end

  response_success(payload: { count: updated_issuables.size })
rescue ArgumentError => e
  response_error(e.message, 422)
end