How do I aggregate activerecord model data for a specific time period?

Posted by gsiener on Stack Overflow See other posts from Stack Overflow or by gsiener
Published on 2010-05-14T02:13:41Z Indexed on 2010/05/14 3:54 UTC
Read the original article Hit count: 280

I'm collecting data from a system every ~10s (this time difference varies due to communication time with networked devices). I'd like to calculate averages and sums of the stored values for this activerecord model on a daily basis. All records are stored in UTC.

What's the correct way to sum and average values for, e.g., the previous day from midnight to midnight EST? I can do this in sql but don't know the "rails way" to make this calculation.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about activerecord