Paginate by time period (e.g. day) instead of a preterdemined size #466
Replies: 1 comment
-
I don't get what you mean. Could you elaborate on that? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Rather than say load 25 items at a time, I want to paginate my ActiveRecord collection by a time period in reverse chronological order.
So page 1 wil show today's created records. Page 2 will show yesterday's created records, and so forth.
However, if there's only a handful of records available I might want to group them by week/month instread. For example if there's a filter applied narrowing down the records a lot, paginating by day might not make sense and I should paginate by week or even month instead.
I implemented some logic for this before, but I'd like to use it with Pagy.
As you can see this takes a collection, and uses Ruby array methods to group the records. This is not ideal because it has to load in all the records into memory.
Any ideas how I can do this properly using Pagy?
I did see the calendar extra, which initially seemed relevant, but I think it's just for filtering on a specific time period whereas I'm talking about paginating all records by a time period.
Beta Was this translation helpful? Give feedback.
All reactions