There are lots of things that can make your life easier. Like cars, planes, electricity, light…Ruby on rails. Ok, let’s be more specific and talk about Groupdate, the simplest way to make easy group queries in SQL. Add various types of charts and use Groupdate to group temporal data in Active Record.
The simplest way to group by:
- day
- week
- hour of the day
- and more (complete list below)
It supports PostgreSQL, MySQL, and Redshift, plus arrays and hashes.
Use it anywhere you can use group
. Works with count
, sum
, minimum
, maximum
, and average
. For median
, check out ActiveMedian. For other aggregate functions, including multiple together, check out CalculateAll.
Groupdate has limited support for SQLite.
- No time zone support
- No
day_start
orweek_start
options - No
group_by_quarter
method
Groupdate 4.0 brings a number of improvements. Here are a few to be aware of:
group_by
methods return anActiveRecord::Relation
instead of aGroupdate::Series
- Invalid options now throw an
ArgumentError
week_start
now affectsday_of_week
- Custom calculation methods are supported by default
As Ruby on Rails agency, we created the new digest with interesting and useful Ruby/Ruby on Rails open source projects.