Ar Chron wrote:
> Ryan King wrote:
>> I'm trying to generate a report for the average number of calls a person
>> makes per-day. The following generates the correct list, but if a user
>> didn't make any calls a certain day it doesn't show up.
>> 
> 
> Why would a day with no calls appear?  Its just reporting the DB data in 
> an aggregated format.
> 
> Merge the returned ave_calls with a list built out of an iteration of 
> from_date to to_date by day to fill the gaps.

call_aves = (Time.now.at_beginning_of_month..Time.now.tomorrow).map{|dt| 
[dt, ave_calls[dt.strftime "%Y-%m-%d"] || 0]}

At first, I just stuck call_aves into the value for Open Flash Charts, 
and it broke it, kind've looked like it went into an infinite loop. So I 
went into my debugger to see what was happening.

irb(#<ReportsController:0x47b7524>):008:0> call_aves[0]
=> [Sat Aug 01 00:00:00 -0400 2009, 0]

As I go up in the array, i notice it's only incrementing by seconds, not 
by days. For example:

irb(#<ReportsController:0x47b7524>):009:0> call_aves[30]
=> [Sat Aug 01 00:00:30 -0400 2009, 0]

How do I get this to go up by the day, not the second?
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to