mirror of
https://github.com/hakanensari/frankfurter.git
synced 2024-11-25 20:42:31 +01:00
e5815737c1
- bumped gems - rm bots - rm pry byebug - added rubocop-shopify and corrected generated warnings
25 lines
608 B
Ruby
25 lines
608 B
Ruby
# frozen_string_literal: true
|
|
|
|
class Day < Sequel::Model
|
|
dataset_module do
|
|
def latest(date = Date.today)
|
|
where(date: select(:date).where(Sequel.lit("date <= ?", date))
|
|
.order(Sequel.desc(:date))
|
|
.limit(1))
|
|
end
|
|
|
|
def between(interval)
|
|
where(date: interval)
|
|
end
|
|
|
|
def currencies
|
|
select(
|
|
:date,
|
|
Sequel.lit("rates.key").as(:iso_code),
|
|
Sequel.lit("rates.value::text::float").as(:rate),
|
|
)
|
|
.join(Sequel.function(:jsonb_each, :rates).lateral.as(:rates), true)
|
|
end
|
|
end
|
|
end
|