Class: GoodJob::DNWorker

Inherits:
HasUtils::GoodJob::BaseWorker
  • Object
show all
Includes:
HasUtils::GoodJob::UniqueJob
Defined in:
app/workers/good_job/dn_worker.rb

Constant Summary collapse

DN_REFRESH_ERROR =
"dn_refresh_error"
DN_SIDEKIQ_CONCURRENCY_ERROR =
"dn_refresh_concurrent_error"

Instance Method Summary collapse

Instance Method Details

#perform(main_table, dependent_tables_and_columns, class_name, record_id, changes, change_log_id) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/workers/good_job/dn_worker.rb', line 18

def perform(main_table, dependent_tables_and_columns, class_name, record_id, changes, change_log_id)
  raw_table_name = main_table
  begin
    ::HasHelpers::DN::Refresh.refresh(
      table_name: raw_table_name,
      table_and_columns: dependent_tables_and_columns,
      class_name: class_name,
      record_id: record_id,
      changes: changes,
      change_log_id: change_log_id
    )
  rescue => e
    save_to_stats(raw_table_name, DN_REFRESH_ERROR, e)
  end
end

#save_to_stats(table_name, subtype, error) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/workers/good_job/dn_worker.rb', line 34

def save_to_stats(table_name, subtype, error)
  stat = ::HasHelpers::Stat.new
  stat.name = table_name
  stat.maintype = "denormalization"
  stat.subtype = subtype
  stat.data = {
    table: table_name,
    error_type: error&.class&.name,
    errors: error&.message
  }
  stat.save!
end