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
Make helpers work without count #944
base: master
Are you sure you want to change the base?
Make helpers work without count #944
Conversation
@attilahorvath This is a very interesting idea. Thanks for bringing this up. I have some thoughts around how we would move forward about this. What's on the table right now is a plan to change all kaminari scopes marked as "without_count" by default. In favor of that we could deprecate the The other thing we can do is to add a |
@yuki24 I think that's an excellent idea to make this the default. Individual developers can then pay the price if they want numbered links for specific pages. My concern was the fact that I had to use a separate view template for non-count result sets that would be the same as our regular Kaminari template, just without these additional links. That would lead to code duplication and we would need to change both templates e.g. if we need to add a new class, which is easy to forget - it's not DRY. I think the gem should gracefully degrade the functionality by only showing prev/next links in this case which is what this PR intends to do. As to how to invoke this behaviour after all scopes are non-count by default, I think we have a couple of options:
class User < ActiveRecord::Base
paginate_without_count
end (For my specific use case that I'm working on right now, this last option would make the most sense.) All of these have their pros and cons and of course we're not limited to just one of these, we could have e.g. both the separate helper and the model-level option as well. Let me know what you think, I can offer my help with the implementation if you want. |
448923a
to
bd5c378
Compare
Fixed that one failing AR 4.1 test in the meantime. |
Mind you that countless paginating is dependent on the way a view is sorted!!! It's not possible to just remember the last ID of an ActiveRecord::Base and then query for a page of records where id > last_seen_id. One must in that case determine what the sort order of the view is and use that to navigate to the next/prev pages. Hardly trivial at all. |
I've been working with somewhat larger data sets lately where
SELECT COUNT
queries would often lead to timeouts. I would like to use thewithout_count
method to solve this issue, however I see no reason why I'd need to change the templates for this, I think the gem could handle this use case automatically by only rendering the prev/next link tags.This PR enables the use of
paginate
andpage_entries_info
with non-count scopes by automatically degrading their features, disabling functionality that can't be used without knowing the result set size.