Groupdate to group temporal data in Active Record

Groupdate to group temporal data in Active Record
Average rating: 5
(1 votes)

Thanks! You’ve rated this material!

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 countsumminimummaximum, 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 or week_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 an ActiveRecord::Relation instead of a Groupdate::Series
  • Invalid options now throw an ArgumentError
  • week_start now affects day_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.

Rate this article, if you like it

Thanks! You’ve rated this material!

Got a project? Let's discuss it!

    Kyiv Sofiivska 1/2a, 01001, Kyiv, Ukraine
    Dnipro Hlinky 2, of. 1003, 49000, Dnipro, Ukraine
    Kharkiv Otakara Yarosha 22, 61000, Kharkiv, Ukraine