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

Pagination #391

Merged
merged 3 commits into from
Sep 24, 2024
Merged

Pagination #391

merged 3 commits into from
Sep 24, 2024

Conversation

ryanlerch
Copy link
Contributor

No description provided.

fix a few issues with the vagrant setup nnot working

Signed-off-by: Ryan Lerch <[email protected]>
this will make it easier in the future when we introduce pagination

Signed-off-by: Ryan Lerch <[email protected]>
@ryanlerch ryanlerch requested a review from abompard September 16, 2024 06:15
mirrormanager2/lib/__init__.py Outdated Show resolved Hide resolved
mirrormanager2/lib/__init__.py Outdated Show resolved Hide resolved
mirrormanager2/templates/fedora/_macros.html Show resolved Hide resolved
@ryanlerch
Copy link
Contributor Author

All issues should be resolved now and ready for re-review.

Copy link
Member

@abompard abompard left a comment

Choose a reason for hiding this comment

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

Looks good! Just one small thing that looks unrelated.

tox.ini Outdated Show resolved Hide resolved
Copy link
Member

@abompard abompard left a comment

Choose a reason for hiding this comment

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

Looking good! Just a possible improvement, nothing mandatory.

Comment on lines 74 to 84
default_page_size = flask.current_app.config["ITEMS_PER_PAGE"]
try:
page_number = int(flask.request.args.get("page_number"))
except (TypeError, ValueError):
page_number = 1

try:
page_size = int(flask.request.args.get("page_size", default_page_size))
except (TypeError, ValueError):
page_size = default_page_size

Copy link
Member

Choose a reason for hiding this comment

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

If you ever want to reuse the PaginationArgs dataclass in another view, you'll have to repeat this conversion block. So I would put that in the constructor of the PaginationArgs class (I think you can do something like that with dataclasses). The aim would be to just pass it flask.request.args.get("page_number") and flask.request.args.get("page_size") and let it do the conversion.
Since it's already a flask-specific class, we could even go as far as letting it set those attributes itself, by having it inspect flask.request. This way we'll have less repetition of code without sacrificing the abstraction layer! :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks yeah i thought about this but didnt investigate if it was possible with dataclasses -- looked at using post_init in dataclasses, but since we are really just setting ti all ourselves in the dataclass itself, i just defined my own init in the dataclass with the logic that previously was in the veiw endpoint.

also added a {posargs} to the lint env in tox so i can -- --fix

Copy link
Member

@abompard abompard left a comment

Choose a reason for hiding this comment

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

Perfect, thanks!

@abompard abompard merged commit 1b668e0 into fedora-infra:master Sep 24, 2024
4 checks passed
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.

2 participants