17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'app/lib/bridge_cache/jobs/import_check.rb', line 17
def perform(account_settings, attempts, chain = [], retries = 0)
@account_settings = account_settings.with_indifferent_access
if spent_time > 90 && remote_data.status == BridgeBlueprint::Constants::STATUS_PENDING
Rails.logger.fatal("Bridge data dump stucked to download after #{spent_time} minutes. Starting again.")
BridgeCache::Jobs::ImportStart.set(queue: queue_name).perform_later(@account_settings, chain, retries - 1)
elsif attempts > max_import_attempts
Rails.logger.fatal("Bridge data dump failed to download after #{spent_time} minutes")
elsif remote_data.status == BridgeBlueprint::Constants::STATUS_COMPLETE
BridgeCache::Jobs::ImportData.set(queue: queue_name).perform_later(@account_settings, chain)
elsif remote_data.status == BridgeBlueprint::Constants::STATUS_PENDING
BridgeCache::Jobs::ImportCheck.set(queue: queue_name, wait: 30.seconds).perform_later(@account_settings,
attempts + 1, chain)
elsif remote_data.status == BridgeBlueprint::Constants::STATUS_FAILED ||
remote_data.status == BridgeBlueprint::Constants::STATUS_NOT_FOUND
raise 'Bridge data dump download failed' if retries < 1
BridgeCache::Jobs::ImportStart.set(queue: queue_name).perform_later(@account_settings, chain, retries - 1)
end
end
|