-
Notifications
You must be signed in to change notification settings - Fork 236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for grouping by every N number of seconds/minutes/etc. #23
Comments
This would be fantastic! Right now I'm doing some crazy stuff and think a more SQL based refactor is in order.
|
+1 Would love this too. |
+1, this feature would be awesome! |
+1, would be great to have this one! |
+1, this would be awesome! |
I'd really like to be able to be group by a customizable amount of days. E.g.:
or perhaps
|
@ankane this is a really old request, any thoughts on closing it or are you still considering it? |
This would be great, as right now there is no option to group by a month exactly from the current date. For instance, I have a record created on the 26th of september, and I want to group only the last 30 days. Right now, if I group by a month this record would be excluded as the group period would start at october 1st. But what I really want is all records created in the last 30 days, starting at 30 days ago and not necessarily begging from the 1st day of the month. I believe #147 would also add this functionality |
Quick update: still happy to review a PR for this. My recommended interface would be group_by_duration(5.minutes, column, options) |
Closing stale feature requests |
Just added this on the gem 'groupdate', github: 'ankane/groupdate', branch: 'group_by_duration' You can use it with: User.group_by_duration(10.minutes, :created_at).count For those still interested in this feature, please let me know your feedback. Notes
My main hesitation with this feature is users will likely be confused by |
IMHO this is a great thing! I just can't test in the nearer future. |
Update: Decided to go with a new option instead of a new method to avoid the confusion mentioned above. User.group_by_minute(:created_at, n: 10).count # 10 minutes It's currently on master with the plan to be released next week. Please let me know if you have any feedback. |
I don't currently see any way to group by something like every 10 minutes. Should be simple to add... just do a mod N after the date_trunc.
The text was updated successfully, but these errors were encountered: