Module: Gera::CurrenciesPurger

Defined in:
lib/gera/currencies_purger.rb

Class Method Summary collapse

Class Method Details

.purge_all(env) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/gera/currencies_purger.rb', line 3

def self.purge_all(env)
  raise unless env == Rails.env

  if Rails.env.prodiction?
    puts 'Disable all sidekiqs'
    Sidekiq::Cron::Job.all.each(&:disable!)
    sleep 2
  end

  DirectionRateSnapshot.batch_purge if DirectionRateSnapshot.table_exists?
  DirectionRate.batch_purge

  ExternalRate.batch_purge
  ExternalRateSnapshot.batch_purge

  CurrencyRate.batch_purge
  RateSource.update_all actual_snapshot_id: nil
  CurrencyRateSnapshot.batch_purge

  if Rails.env.prodiction?
    puts 'Enable all sidekiqs'
    Sidekiq::Cron::Job.all.each(&:enable!)
  end
end