Skip to content

Commit

Permalink
HOTT-2212 Addressed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jebw committed Nov 18, 2022
1 parent f8b6d10 commit e0634dc
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions app/workers/updates_synchronizer_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,10 @@ def perform(check_for_todays_file = true, reapply_data_migrations = false)
if TradeTariffBackend.uk?
TariffSynchronizer.download_cds

if check_for_todays_file && todays_file_has_not_yet_arrived?
if still_time_to_reschedule?
self.class.perform_in(TRY_AGAIN_IN, true)
logger.info "Daily file missing, retrying at #{TRY_AGAIN_IN.from_now}"
return
else
SlackNotifierService.call \
'Daily CDS file missing, max retry time passed - continuing without todays file'
end
if check_for_todays_file &&
todays_file_has_not_yet_arrived? &&
attempt_reschedule!
return
end

logger.info 'Applying...'
Expand Down Expand Up @@ -65,4 +60,16 @@ def migrate_data
require 'data_migrator' unless defined?(DataMigrator)
DataMigrator.migrate_up!(nil)
end

def attempt_reschedule!
if still_time_to_reschedule?
self.class.perform_in(TRY_AGAIN_IN, true)
logger.info "Daily file missing, retrying at #{TRY_AGAIN_IN.from_now}"
true
else
SlackNotifierService.call \
'Daily CDS file missing, max retry time passed - continuing without todays file'
false
end
end
end

0 comments on commit e0634dc

Please sign in to comment.