Groupdate is a Ruby library that groups temporal data by time periods in database queries.
The library solves the problem of aggregating time-series data across various time intervals—from seconds to years, as well as derived periods like day of week or hour of day. It works by translating grouping operations into database-native SQL, supporting PostgreSQL, MySQL, MariaDB, SQLite, and Redshift. A key strength is its handling of time zones, including daylight saving time transitions, which the README emphasizes as a primary feature. The tool also returns complete series by default, filling in periods with no data rather than omitting them, and keys are returned as date or time objects representing the period start.
Groupdate suits Rails applications that need to aggregate temporal metrics for reporting or visualization. It works anywhere Active Record's `group` method applies and integrates with aggregation functions like `count`, `sum`, `minimum`, `maximum`, and `average`. The README notes it pairs well with Chartkick for visualization. Developers can customize behavior through options like time zone selection, week start day, day start hour, time ranges, key formatting, and whether to include empty periods. For MySQL and MariaDB, time zone support must be explicitly installed on the server.
The project maintains a straightforward development posture with a dedicated changelog and explicit contribution guidelines. It accepts bug reports, pull requests, and documentation improvements through standard GitHub workflows, with a contributing guide available for those wanting to participate in development and testing.