Class: GoodJob::ConfigurableBackfill
- Inherits:
-
HasUtils::GoodJob::BaseWorker
- Object
- HasUtils::GoodJob::BaseWorker
- GoodJob::ConfigurableBackfill
- Includes:
- HasUtils::GoodJob::UniqueJob
- Defined in:
- app/workers/good_job/configurable_backfill.rb
Constant Summary collapse
- STARTED =
"STARTED"- FINISHED =
"FINISHED"- LOCKED =
"LOCKED"- STAT_TYPE =
"denormalization"- STAT_SUBTYPE =
"configurable_backfill"- COLUMNS_DENORMALIZED =
{ texts: "::GoodJob::DN::BackfillTextDenormalization" }
Instance Method Summary collapse
- #backfill_run(backfill_name, **options) ⇒ Object
- #backfill_tables(table_names, **options) ⇒ Object
- #perform(table_names = [], options = {}) ⇒ Object
- #save_to_stats(name, type, subtype, data, _starting_time, _ending_time = 0) ⇒ Object
Instance Method Details
#backfill_run(backfill_name, **options) ⇒ Object
50 51 52 53 |
# File 'app/workers/good_job/configurable_backfill.rb', line 50 def backfill_run(backfill_name, **) # execute the backfills corresponding to the resource backfill_name.classify.constantize.new.run(**) end |
#backfill_tables(table_names, **options) ⇒ Object
44 45 46 47 48 |
# File 'app/workers/good_job/configurable_backfill.rb', line 44 def backfill_tables(table_names, **) table_names.each do |table_name| backfill_run(COLUMNS_DENORMALIZED[table_name.to_sym], **) end end |
#perform(table_names = [], options = {}) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/workers/good_job/configurable_backfill.rb', line 32 def perform(table_names = [], = {}) starting_time = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC) save_to_stats(table_names, STAT_TYPE, STAT_SUBTYPE, { table: table_names, options: , status: STARTED, errors: nil }, starting_time, starting_time) begin backfill_tables(table_names, **) rescue => e save_to_stats(table_names, STAT_TYPE, STAT_SUBTYPE, { table: table_names, options: , status: LOCKED, errors: e&. }, starting_time, ::Process.clock_gettime(::Process::CLOCK_MONOTONIC)) return end save_to_stats(table_names, STAT_TYPE, STAT_SUBTYPE, { table: table_names, options: , status: FINISHED, errors: nil }, starting_time, ::Process.clock_gettime(::Process::CLOCK_MONOTONIC)) end |
#save_to_stats(name, type, subtype, data, _starting_time, _ending_time = 0) ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'app/workers/good_job/configurable_backfill.rb', line 55 def save_to_stats(name, type, subtype, data, _starting_time, _ending_time = 0) stat = ::HasHelpers::Stat.new stat.name = name stat.maintype = type stat.subtype = subtype stat.data = data stat.save! end |