mirror of
https://github.com/hakanensari/frankfurter.git
synced 2024-11-25 20:42:31 +01:00
25 lines
469 B
Ruby
25 lines
469 B
Ruby
# frozen_string_literal: true
|
|
|
|
namespace :rates do
|
|
task setup: :environment do
|
|
require 'currency'
|
|
require 'fixer'
|
|
end
|
|
|
|
desc 'Load all rates'
|
|
task load: :setup do
|
|
Currency.db.transaction do
|
|
Currency.dataset.delete
|
|
data = Fixer::Feed.new(:historical)
|
|
Currency.multi_insert(data.to_a)
|
|
end
|
|
end
|
|
|
|
desc 'Update rates'
|
|
task update: :setup do
|
|
Fixer::Feed.new.each do |hsh|
|
|
Currency.find_or_create(hsh)
|
|
end
|
|
end
|
|
end
|