Rob Biedenharn wrote in post #972151:
[...]
> You might also just get the counts from the database directly:
> results = User.find(:all,
>      :select => 'DATE(created_at) as create_date, COUNT(*) as
> user_count',
>      :conditions => { :created_at => start_date..end_date },
>      :group => 'DATE(created_at)').
>    map{|u| [Date.parse(u.create_date), u.user_count.to_i]}
> data = date_range.map {|d| [d.strftime("%d %b"),
>                              (results.assoc(d) || [nil,0])[1]] }

Or better yet, use User.count instead of .find .

>
> -Rob
>
> Rob Biedenharn
> [email protected]  http://AgileConsultingLLC.com/
> [email protected]    http://GaslightSoftware.com/

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

-- 
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