diff --git a/CHANGELOG.md b/CHANGELOG.md index 246c732..a543859 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lib/currency.rb b/lib/currency.rb index 32d58ed..a52fbdc 100644 --- a/lib/currency.rb +++ b/lib/currency.rb @@ -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 diff --git a/spec/currency_spec.rb b/spec/currency_spec.rb index 9bff185..e1bf94c 100644 --- a/spec/currency_spec.rb +++ b/spec/currency_spec.rb @@ -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