This commit is contained in:
Hakan Ensari 2020-05-02 15:18:52 +01:00
parent ec302e726c
commit 2e83b9d50d
3 changed files with 8 additions and 8 deletions

View File

@ -4,7 +4,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]
### Changed
- Sample weekly when querying over 365 days
- Sample weekly when querying over a year
- Bump PostgreSQL to 12
## 1.0.0 - 2020-01-02

View File

@ -17,7 +17,7 @@ class Currency < Sequel::Model(Day.currencies)
def between(interval)
case interval.last - interval.first
when 91.. then super.sample('week')
when 366.. then super.sample('week')
else super
end
end

View File

@ -16,14 +16,14 @@ describe Currency do
Date.parse('2010-01-01')
end
it 'returns everything up to 90 days' do
interval = day..day + 90
Currency.between(interval).map(:date).uniq.count.must_be :>, 30
it 'returns everything up to a year' do
interval = day..day + 365
Currency.between(interval).map(:date).uniq.count.must_be :>, 52
end
it 'samples weekly over 90 days' do
interval = day..day + 365
Currency.between(interval).map(:date).uniq.count.must_be :<=, 52
it 'samples weekly over a year' do
interval = day..day + 366
Currency.between(interval).map(:date).uniq.count.must_be :<, 54
end
it 'sorts by date' do