Skip to content
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

Adding max_pages for pagination response #614

Closed
wants to merge 1 commit into from
Closed

Adding max_pages for pagination response #614

wants to merge 1 commit into from

Conversation

jeremyf
Copy link
Contributor

@jeremyf jeremyf commented Sep 23, 2013

Kaminari is expecting that max_pages exist

@cbeer
Copy link
Member

cbeer commented Sep 23, 2013

I don't understand the semantics of Kaminari's max_pages, but I don't think it's the total number of pages (see #total_pages / #num_pages).

The only relevant rubydoc I can find says:

This model's max_pages value returns max_pages value unless explicitly overridden via max_pages_per.

In the code, it seems like this is a ceiling for the number of pages for any result set:

if max_pages.present? && max_pages < total_pages_count
        max_pages
      else

With that logic, maybe we should just return nil?

@jeremyf
Copy link
Contributor Author

jeremyf commented Sep 23, 2013

nil would be fine by me; I'll amend the commit

@cbeer
Copy link
Member

cbeer commented Sep 23, 2013

I'm also trying to figure out what version that logic was introduced. It might be time to pin blacklight to that version (or, at least, pin our testing to something recent?)

Kaminari is expecting that max_pages exist
@jeremyf
Copy link
Contributor Author

jeremyf commented Sep 23, 2013

@cbeer pushed the update to set as nil

@jcoyne
Copy link
Member

jcoyne commented Sep 23, 2013

Was added here: amatsuda/kaminari@c180703
So 0.14.1 (released a year ago)

@cbeer
Copy link
Member

cbeer commented Sep 23, 2013

Ah, so it isn't in a Kaminari release yet?

@jcoyne
Copy link
Member

jcoyne commented Sep 23, 2013

Cbeer: That code was released a year ago.

@cbeer
Copy link
Member

cbeer commented Sep 23, 2013

@jcoyne
Copy link
Member

jcoyne commented Sep 23, 2013

You're right. Looks like it's just on master.

-Justin

On Mon, Sep 23, 2013 at 11:39 AM, Chris Beer notifications@github.hscsec.cnwrote:

Is it? I don't see it in:

https://github.com/amatsuda/kaminari/blob/v0.14.1/lib/kaminari/models/configuration_methods.rb


Reply to this email directly or view it on GitHubhttps://github.com//pull/614#issuecomment-24933858
.

@cbeer
Copy link
Member

cbeer commented Sep 23, 2013

So.. should we merge this in anticipation of the kaminari release that will require this method? Or wait for them to settle on an API (and maybe provide this behavior for free..)

@jeremyf
Copy link
Contributor Author

jeremyf commented Sep 23, 2013

The reason for this pull request is that I'm having to peg to a specific version of blacklight in my repo.

We are referencing gem 'kaminari', github: 'harai/kaminari', branch: 'route_prefix_prototype' for curate/sufia, which must've incorporated that method.

@jcoyne
Copy link
Member

jcoyne commented Sep 23, 2013

@jeremyf Sufia is using that branch of kaminari too, but hasn't had any trouble with "max_pages". How are you triggering that error?

Also, I'm not sure the test you added belongs in the grouping response spec. Shouldn't it be in the most generic kind of response spec?

@MrDys
Copy link
Contributor

MrDys commented Sep 23, 2013

So, you're referencing a non-master branch of fork of kaminari? Seems like
something that should not be directly dealt with in blacklight until it
shows up in a main kaminari release.

On Mon, Sep 23, 2013 at 3:13 PM, Jeremy Friesen notifications@github.hscsec.cnwrote:

The reason for this pull request is that I'm having to peg to a specific
version of blacklight in my repo.

We are referencing gem 'kaminari', github: 'harai/kaminari', branch:
'route_prefix_prototype' for curate/sufia, which must've incorporated
that method.


Reply to this email directly or view it on GitHubhttps://github.com//pull/614#issuecomment-24945835
.

@jeremyf
Copy link
Contributor Author

jeremyf commented Sep 23, 2013

@jcoyne - Yes it should belong in the generic response spec…but I didn't see one so I went hunting.

Regarding sufia, I'm not entirely certain why it isn't triggering.

@MrDys - Without diving deeper into implementation details, it looks like master has some knowledge of max_pages within the mixin, but in that module does not explicitly define the max_pages method. What I suspect, based on a 1 minute sweep of the code is that this is now a config option that gets mixed in.

I am looking at as a reference point: https://github.com/amatsuda/kaminari/blob/master/lib/kaminari/models/page_scope_methods.rb#L27

@jcoyne
Copy link
Member

jcoyne commented Sep 23, 2013

@MrDys The fork that is being referenced has a critical fix for those of us
working with mountable engines (that use Blacklight). The maintainer of
kaminari is just ignoring that pull request which has been open for 9
months.

On Mon, Sep 23, 2013 at 2:45 PM, Jeremy Friesen notifications@github.hscsec.cnwrote:

@jcoyne https://github.com/jcoyne - Yes it should belong in the generic
response spec…but I didn't see one so I went hunting.

Regarding sufia, I'm not entirely certain why it isn't triggering.

@MrDys https://github.com/MrDys - Without diving deeper into
implementation details, it looks like master has some knowledge of
max_pages within the mixin, but in that module does not explicitly define
the max_pages method. What I suspect, based on a 1 minute sweep of the code
is that this is now a config option that gets mixed in.

I am looking at as a reference point:
https://github.com/amatsuda/kaminari/blob/master/lib/kaminari/models/page_scope_methods.rb#L27


Reply to this email directly or view it on GitHubhttps://github.com//pull/614#issuecomment-24948336
.

@jcoyne
Copy link
Member

jcoyne commented Sep 23, 2013

@jeremyf suddenly this error has manifest in sufia: https://travis-ci.org/projecthydra/sufia/jobs/11710850

@jcoyne
Copy link
Member

jcoyne commented Sep 24, 2013

👍

@cbeer
Copy link
Member

cbeer commented Sep 24, 2013

In 59a15be, I figured out where max_pages was provided (and used by other kaminari-internal integrations) and included it in our own mixin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants