Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

WIP: Implement pagination headers #27

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

Conversation

rambobinator
Copy link
Contributor

Hi,
I PR this as apparently there is a need (@trubesv ).
At least we can discuss the implementation.

flask_stupe/json.py Outdated Show resolved Hide resolved
flask_stupe/request.py Show resolved Hide resolved
flask_stupe/pagination.py Outdated Show resolved Hide resolved
flask_stupe/pagination.py Show resolved Hide resolved
flask_stupe/pagination.py Outdated Show resolved Hide resolved
flask_stupe/pagination.py Outdated Show resolved Hide resolved
flask_stupe/pagination.py Outdated Show resolved Hide resolved
flask_stupe/pagination.py Outdated Show resolved Hide resolved
@ramnes
Copy link
Collaborator

ramnes commented Nov 28, 2018

It lacks a test case, though.

Yep, it really does!

Also, check the Travis build, it's failing.

@trubesv trubesv added the enhancement New feature or request label Nov 28, 2018
flask_stupe/pagination.py Outdated Show resolved Hide resolved
flask_stupe/pagination.py Outdated Show resolved Hide resolved
@trubesv trubesv changed the title WIP: Issue #19 Implement pagination headers (fixes #19) Nov 28, 2018
@trubesv trubesv changed the title Implement pagination headers (fixes #19) Implement pagination headers Nov 28, 2018
flask_stupe/pagination.py Outdated Show resolved Hide resolved
flask_stupe/pagination.py Outdated Show resolved Hide resolved
@coveralls
Copy link

coveralls commented Nov 28, 2018

Pull Request Test Coverage Report for Build 130

  • 36 of 36 (100.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 108: 0.0%
Covered Lines: 399
Relevant Lines: 399

💛 - Coveralls

tests/json.py Outdated
response = client.get("/")
assert response.status_code == 200

assert "X-Total-Count" in response.headers
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
assert "X-Total-Count" in response.headers
assert response.headers["X-Total-Count"] == 3

Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we really need both tests then?

Copy link
Collaborator

@ramnes ramnes Nov 28, 2018

Choose a reason for hiding this comment

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

Right. But then a similar test should be done in tests/app.py, because we want the headers mode to work also with the non-json Stupeflask version.

tests/json.py Outdated Show resolved Hide resolved
flask_stupe/pagination.py Outdated Show resolved Hide resolved
tests/pagination.py Outdated Show resolved Hide resolved
@trubesv trubesv force-pushed the feature/pagination_headers branch 2 times, most recently from 4fdb4a2 to 719bc27 Compare November 28, 2018 14:55
flask_stupe/pagination.py Outdated Show resolved Hide resolved
flask_stupe/pagination.py Show resolved Hide resolved
flask_stupe/pagination.py Outdated Show resolved Hide resolved
flask_stupe/pagination.py Outdated Show resolved Hide resolved
flask_stupe/pagination.py Outdated Show resolved Hide resolved
tests/pagination.py Outdated Show resolved Hide resolved
@trubesv trubesv changed the title Implement pagination headers WIP: Implement pagination headers Nov 28, 2018
@rambobinator
Copy link
Contributor Author

Concerning the current implementation, i tried to stick to the RFC linked by @tobes. Don't you think it's the best thing to do ?
https://tools.ietf.org/html/rfc5988#page-6

tests/pagination.py Outdated Show resolved Hide resolved
@trubesv trubesv force-pushed the feature/pagination_headers branch 2 times, most recently from af1196e to 8ba04d7 Compare November 28, 2018 17:03
@ramnes
Copy link
Collaborator

ramnes commented Nov 28, 2018

Don't we want the dict values in the body to only contain the links, without the >; rel='...' part?

@trubesv trubesv force-pushed the feature/pagination_headers branch 3 times, most recently from 9d544ef to f047dc9 Compare November 29, 2018 10:11
@ramnes
Copy link
Collaborator

ramnes commented Nov 29, 2018

PyMongo already handles that for the limit: it keeps the absolute value and consider 0 as "no limit". We might want to validate that skip is a positive integer though, or just handle the ValueError that PyMongo would raise.

@ramnes
Copy link
Collaborator

ramnes commented Nov 29, 2018

I think we should simply not offer the relatives links if we're on an edge.

@trubesv trubesv added the low priority This fix/feature would be nice to have label Nov 29, 2018
@trubesv trubesv requested review from pacud and removed request for trubesv November 29, 2018 16:59
@trubesv trubesv self-assigned this Nov 30, 2018
@trubesv trubesv force-pushed the feature/pagination_headers branch 2 times, most recently from b3091dc to f076ac7 Compare December 13, 2018 10:12
Fixes #19

TODO:
- Implement & test header Link for bare Flask app
@ramnes ramnes force-pushed the master branch 2 times, most recently from deca4d9 to 1690fda Compare August 21, 2019 09:45
@trubesv trubesv removed their assignment Apr 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request low priority This fix/feature would be nice to have
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants