From d0a91882e3649959c8e8a6806b46892f9ea62716 Mon Sep 17 00:00:00 2001 From: Loos Date: Mon, 22 Dec 2014 12:40:47 -0600 Subject: [PATCH] Louis | Reports work with unsold bikes --- app/models/report.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/report.rb b/app/models/report.rb index 251f050..1d394d6 100644 --- a/app/models/report.rb +++ b/app/models/report.rb @@ -1,6 +1,6 @@ class Report - @@years = Bike.all.each.map{|bike| Time.parse(bike.date_sold).year if bike.date_sold} + @@years = Bike.all.each.map{|bike| bike.date_sold.year if bike.date_sold} def self.bikes_sold_per_year counts = Hash.new(0) @@ -29,6 +29,7 @@ class Report average_price_per_year = Report.average_price_per_year() yearly_data_array = unique_years.map{|year| {year => {number: bikes_sold_per_year[year], average_price: average_price_per_year[year]}}} yearly_data = yearly_data_array.reduce({}, :merge) + yearly_data.delete(nil) Hash[yearly_data.sort] end