Class: LcpRuby::BatchActions::BatchActionHandler

Inherits:
LcpRuby::BackgroundJobs::BaseHandler show all
Defined in:
lib/lcp_ruby/batch_actions/batch_action_handler.rb

Instance Attribute Summary

Attributes inherited from LcpRuby::BackgroundJobs::BaseHandler

#definition, #execution

Instance Method Summary collapse

Methods inherited from LcpRuby::BackgroundJobs::BaseHandler

#attach_result!, #check_cancellation!, #flush_log!, #initialize, #log!, #params, #set_result_url!, #target_record, #triggered_by, #update_progress!

Constructor Details

This class inherits a constructor from LcpRuby::BackgroundJobs::BaseHandler

Instance Method Details

#performObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/lcp_ruby/batch_actions/batch_action_handler.rb', line 22

def perform
  @action_name = params["action_name"]
  @model_name = params["model_name"]
  @user = load_user
  @evaluator = build_evaluator
  @model_def = resolve_model_definition
  @records = resolve_records
  @batch_op = load_batch_operation

  log!("Starting batch #{@action_name} on #{@model_name}")
  total = @records.count
  log!("Record count: #{total}")

  result = if built_in_action?(@action_name)
    execute_built_in(total)
  else
    execute_custom
  end

  log!(result.message)
  broadcast_model_change(@model_name)
end