<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/stylesheets/rss.css" type="text/css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>I.NFECTIO.US: Tag calculations</title>
    <link>http://i.nfectio.us/articles/tag/calculations</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>"Nothing in life is worth doing if you have no life while doing it"</description>
    <item>
      <title>ActiveRecord Calculations</title>
      <description>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.

&lt;pre&gt;
# 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 =&gt; 'number_of_views'}, :replies, :order =&gt; "number_of_views desc") 
&lt;/pre&gt;

&lt;a href="http://dev.rubyonrails.org/ticket/6552"&gt;Multiple Calculations Patch&lt;/a&gt;
&lt;br /&gt;&lt;br /&gt;</description>
      <pubDate>Sun, 05 Nov 2006 12:38:00 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:f9e40c1f-0b94-48a4-81b7-d04a0f9475cd</guid>
      <author>Bob Silva</author>
      <link>http://i.nfectio.us/articles/2006/11/05/activerecord-calculations</link>
      <category>Ruby on Rails</category>
      <category>rails</category>
      <category>patch</category>
      <category>calculations</category>
    </item>
  </channel>
</rss>
