Class: Gera::CBRRatesWorker

Inherits:
Object
  • Object
show all
Includes:
AutoLogger, Sidekiq::Worker
Defined in:
app/workers/gera/cbr_rates_worker.rb

Overview

Import rates from Russian Central Bank www.cbr.ru/scripts/XML_daily.asp?date_req=08/04/2018

Constant Summary collapse

CURRENCIES =
%w[USD KZT EUR UAH].freeze
CBR_IDS =
{
  'USD' => 'R01235',
  'KZT' => 'R01335',
  'EUR' => 'R01239',
  'UAH' => 'R01720'
}.freeze
ROUND =
15
Error =
Class.new StandardError
WrongDate =
Class.new Error
URL =
'http://www.cbr.ru/scripts/XML_daily.asp'

Instance Method Summary collapse

Instance Method Details

#performObject



30
31
32
33
34
35
36
37
38
39
# File 'app/workers/gera/cbr_rates_worker.rb', line 30

def perform
  ActiveRecord::Base.connection.clear_query_cache
  cbr.with_lock do
    days.each do |date|
      fetch_and_save_rate date
    end

    make_snapshot
  end
end