Skip to content

Commit

Permalink
Re-add missing route
Browse files Browse the repository at this point in the history
  • Loading branch information
Calyhre committed May 26, 2017
1 parent b6e6700 commit 21224d8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
20 changes: 19 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def best_deals
lowest = games.flat_map(&:prices).min_by { |price| price.value.exchange_to('USD') }
next if lowest.blank?
rates = currencies.map { |c| lowest.value.exchange_to(c).format }
rows << [game.first.title, ISO3166::Country[lowest.country].translation('en')].concat(rates)
rows << [games.first.title, ISO3166::Country[lowest.country].translation('en')].concat(rates)
end
end

Expand Down Expand Up @@ -45,6 +45,24 @@ def glossary
send_data csv, type: 'text/csv; charset=utf-8; header=present'
end

def rates
currencies = Price.distinct.pluck(:currency).sort

csv = CSV.generate(headers: true) do |rows|
rows << [''].concat(currencies)

currencies.each do |from|
row = [from]
currencies.each do |to|
row << Money.default_bank.get_rate(from, to)
end
rows << row
end
end

send_data csv, type: 'text/csv; charset=utf-8; header=present'
end

def about
csv = CSV.generate(headers: true) do |rows|
rows << ['Page url', 'http://eshop.calyh.re']
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/eshop.rake
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace :eshop do

desc 'Detect new shops that were not selling games before'
task detect_new_shops: :environment do
ids = Game.distinct.pluck(:nsuid).compact.sample(50)
ids = Game.distinct.pluck(:nsuid).compact
new_shops = []
puts "Retrieving #{ids.count} prices..."
countries = Eshop::REGIONS.values.flatten.uniq.sort - Eshop::COUNTRIES
Expand Down

0 comments on commit 21224d8

Please sign in to comment.