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

Update Pagy:: Backend comment #745

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

leonvogt
Copy link

Hi 👋

I've noticed that the overriding of pagy_get_vars stopped working after the 9.0.0 upgrade.
It seems this method was removed during this refactoring.

In my use case, I was able to switch to overriding pagy_get_count instead.

I've updated the comment to reflect this change.

@@ -3,7 +3,7 @@

class Pagy
# Define a few generic methods to paginate a collection out of the box,
# or any collection by overriding pagy_get_items and/or pagy_get_vars in your controller
# or any collection by overriding pagy_get_items and/or pagy_get_count in your controller
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely spotted!

-  pagy_get_vars
+  pagy_get_count

Any of the pagy_get_ methods may be overridden (for whatever reason): should we alert users to this possibility rather than confine the patch to just pagy_get_items and pagy_get_count?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any of the pagy_get_* methods...

👍🏼 @benkoshy since it's a code comment... yes, a general comment may be more appropriate.

We should consider also adapting it to the backend extras.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benkoshy Ah yes fair enough. I wasn't sure so I went for the least changes.
Ive updated the comment to:

# Define a few generic methods to paginate a collection out of the box,
# or any collection by overriding any of the `pagy_get_` methods in your controller.
# See also the extras if you need specialized methods to paginate Arrays or other collections

Do you think that's better? Or do you have some better suggestions?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think that's better? Or do you have some better suggestions?

Looks great!

BTW: if you want bonus marks - consider adapting a similar comment in the "extras". i.e. to alert to the possibility that those methods can be overridden. Or I can do it for you and credit you with the PR.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider adapting a similar comment in the "extras".

Hm, are you talking about the Pagy::PagyExtra?
I've never overridden those and I'm not sure if I can provide a clear comment instruction on how to override them.
Seems like you need make some extra steps to override frontend methods.

I would be happy if someone else with actual experience can provide a comment there.

Copy link
Collaborator

@benkoshy benkoshy Oct 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, are you talking about the Pagy::PagyExtra?

Pagy has some "extras" with methods that be overriden. A comment similar to what you suggested above would suffice?

@ddnexus
Copy link
Owner

ddnexus commented Oct 18, 2024

This PR requires a rebase on master in order to pass the tests.

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.

3 participants