mirror of
https://github.com/hakanensari/frankfurter.git
synced 2024-11-22 11:02:30 +01:00
cfbb4ac4ac
I'm moving my company's server to a private location now that I have sold the domain. While prepping for this, I've done some cleanup and also threw in changes I had lingering on my hard drive. - Run a single database query instead of two - Fold the gem into the app and use Ox instead of REXML - Simplify error handling logic - Relax throttling
22 lines
398 B
Ruby
22 lines
398 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'currency'
|
|
require 'bank/feed'
|
|
|
|
module Bank
|
|
def self.fetch_all_rates!
|
|
Currency.db.transaction do
|
|
Currency.dataset.delete
|
|
Currency.multi_insert(Feed.historical.to_a)
|
|
end
|
|
end
|
|
|
|
def self.fetch_current_rates!
|
|
Currency.db.transaction do
|
|
Feed.current.each do |hsh|
|
|
Currency.find_or_create(hsh)
|
|
end
|
|
end
|
|
end
|
|
end
|