Class: AtlasEngine::AddressImporter::ClearRecordsJob
- Inherits:
-
ResumableImportJob
- Object
- ActiveJob::Base
- AtlasEngine::ApplicationJob
- ResumableImportJob
- AtlasEngine::AddressImporter::ClearRecordsJob
- Includes:
- ImportLogHelper, LogHelper
- Defined in:
- app/jobs/atlas_engine/address_importer/clear_records_job.rb
Constant Summary collapse
- DELETION_BATCH_SIZE =
2000
Constants included from ImportLogHelper
ImportLogHelper::TEST_TIMESTAMP
Instance Method Summary collapse
- #build_enumerator(params, cursor:) ⇒ Object
- #clear_records ⇒ Object
- #delete_rows ⇒ Object
- #each_iteration(batch, params) ⇒ Object
Methods included from LogHelper
#log_error, #log_info, #log_warn
Methods included from ImportLogHelper
#import_log_error, #import_log_info
Methods inherited from ResumableImportJob
#country_import, #log_final_stats
Methods inherited from AtlasEngine::ApplicationJob
Instance Method Details
#build_enumerator(params, cursor:) ⇒ Object
11 12 13 |
# File 'app/jobs/atlas_engine/address_importer/clear_records_job.rb', line 11 def build_enumerator(params, cursor:) enumerator_builder.build_times_enumerator(1, cursor: cursor) end |
#clear_records ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'app/jobs/atlas_engine/address_importer/clear_records_job.rb', line 20 def clear_records import_log_info( country_import: country_import, message: "Clearing all records from PostAddress where country_code: #{@country_code}...", ) rows_deleted = delete_rows rows_deleted = delete_rows until rows_deleted != DELETION_BATCH_SIZE import_log_info(country_import: country_import, message: "PostAddress records cleared.") end |
#delete_rows ⇒ Object
30 31 32 33 34 35 36 |
# File 'app/jobs/atlas_engine/address_importer/clear_records_job.rb', line 30 def delete_rows PostAddress.connection.exec_delete( "DELETE FROM #{PostAddress.table_name} where country_code = '#{@country_code}' LIMIT #{DELETION_BATCH_SIZE}", "DELETE", [], ) end |
#each_iteration(batch, params) ⇒ Object
15 16 17 18 |
# File 'app/jobs/atlas_engine/address_importer/clear_records_job.rb', line 15 def each_iteration(batch, params) @country_code = params[:country_code] clear_records end |