ActiveRecord Calculations 4
I've been wanting to modify the ActiveRecord Calculations module to support multiple aggregate calculations in one query for awhile now. My current project with lots of graphing finally gave me the motivation to do it. Refer to the patch for details and feel free to comment on it.
# Calculate different aggregate functions at once
min, max = Person.calculate(:min, :age, :max, :age)
# Specify the column aliases so you can order by it
views, replies = Posts.sum({:views => 'number_of_views'}, :replies, :order => "number_of_views desc")
Multiple Calculations Patch
Comments
-
Hi Bob, very cooll... so what are you using for graphing? Gruff? I'll have to do graphing pretty soon and it doesn't like there are many options out there.
-
I use the Ruby bindings with ASE ChartDirector at http://www.advsofteng.com/
-
I would love to try this. How do I use the .diff file? Thanks.
-
Hi! Is this still possible to use this patch with Rails 1.2?