mirror of
https://github.com/hakanensari/frankfurter.git
synced 2024-11-22 02:52:49 +01:00
28 lines
556 B
Ruby
28 lines
556 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'currency'
|
|
require 'bank/feed'
|
|
|
|
module Bank
|
|
def self.fetch_all!
|
|
Currency.dataset.insert_conflict.multi_insert(Feed.historical.to_a)
|
|
end
|
|
|
|
def self.fetch_ninety_days!
|
|
Currency.dataset.insert_conflict.multi_insert(Feed.ninety_days.to_a)
|
|
end
|
|
|
|
def self.fetch_current!
|
|
Currency.db.transaction do
|
|
Feed.current.each do |hsh|
|
|
Currency.find_or_create(hsh)
|
|
end
|
|
end
|
|
end
|
|
|
|
def self.replace_all!
|
|
Currency.dataset.delete
|
|
Currency.multi_insert(Feed.historical.to_a)
|
|
end
|
|
end
|