diff --git a/app/models/statistics.rb b/app/models/statistics.rb index 6878e5ae0e..6f252ac8b4 100644 --- a/app/models/statistics.rb +++ b/app/models/statistics.rb @@ -129,6 +129,8 @@ def by_week_to_today_with_noughts(counts_by_week, start_date) earliest_week = start_date.to_date.at_beginning_of_week latest_week = Date.current.at_beginning_of_week + counts_by_week.map! { |date, count| [date.to_s, count] } + (earliest_week..latest_week).step(7) do |date| counts_by_week << [date.to_s, 0] unless counts_by_week.any? { |c| c.first == date.to_s } end diff --git a/config/initializers/alaveteli.rb b/config/initializers/alaveteli.rb index 58dab0fda2..d0ae6eed40 100644 --- a/config/initializers/alaveteli.rb +++ b/config/initializers/alaveteli.rb @@ -11,7 +11,7 @@ load "util.rb" # Application version -ALAVETELI_VERSION = '0.28.0.4' +ALAVETELI_VERSION = '0.28.0.5' # Add new inflection rules using the following format # (all these examples are active by default): diff --git a/doc/CHANGES.md b/doc/CHANGES.md index ed92033e30..216d799c42 100644 --- a/doc/CHANGES.md +++ b/doc/CHANGES.md @@ -1,3 +1,10 @@ +# 0.28.0.5 + +# Highlighted Features + +* Fix bug in `Statistics.by_week_to_today_with_noughts` causing comparisons to + fail (Gareth Rees) + # 0.28.0.4 # Highlighted Features diff --git a/spec/models/statistics_spec.rb b/spec/models/statistics_spec.rb index e2323395dd..b5022dc387 100644 --- a/spec/models/statistics_spec.rb +++ b/spec/models/statistics_spec.rb @@ -123,8 +123,8 @@ describe ".by_week_to_today_with_noughts" do it "adds missing weeks with noughts" do data = [ - ["2016-01-04", 2], - ["2016-01-18", 1] + [Date.parse("2016-01-04"), 2], + [Date.parse("2016-01-18"), 1] ] date_from = Date.new(2015, 12, 28) fake_current_date = Date.new(2016, 1, 31)