-
Notifications
You must be signed in to change notification settings - Fork 49
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
Pagination #391
Conversation
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]>
010f029
to
4bb666a
Compare
All issues should be resolved now and ready for re-review. |
There was a problem hiding this 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.
4bb666a
to
e325583
Compare
There was a problem hiding this 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.
mirrormanager2/views.py
Outdated
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 | ||
|
There was a problem hiding this comment.
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! :-)
There was a problem hiding this comment.
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
Resolves: fedora-infra#346 Signed-off-by: Ryan Lerch <[email protected]>
e325583
to
e2d3869
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, thanks!
No description provided.