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

Add database page limit #139

Merged
merged 3 commits into from Jan 20, 2020
Merged

Add database page limit #139

merged 3 commits into from Jan 20, 2020

Conversation

CasperWA
Copy link
Member

@CasperWA CasperWA commented Jan 17, 2020

Adds the concept a maximum database limit to what the database will return in a single request.

Essentially it sets a maximum limit for the page_limit query parameter.
This makes the page_limit concept from the config files a default page_limit.

Note: This is based on the work from #137, so this should not be merged before that PR, and should be merged via "Rebase and merge".

@CasperWA CasperWA requested a review from ml-evs January 17, 2020 16:15
@codecov
Copy link

codecov bot commented Jan 17, 2020

Codecov Report

Merging #139 into master will increase coverage by 0.06%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #139      +/-   ##
==========================================
+ Coverage   86.12%   86.18%   +0.06%     
==========================================
  Files          39       39              
  Lines        1816     1824       +8     
==========================================
+ Hits         1564     1572       +8     
  Misses        252      252
Flag Coverage Δ
#unittests 86.18% <100%> (+0.06%) ⬆️
Impacted Files Coverage Δ
optimade/server/routers/utils.py 83.73% <100%> (+0.4%) ⬆️
optimade/server/config.py 93.26% <100%> (+0.13%) ⬆️
optimade/server/routers/info.py 96.29% <100%> (+0.46%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bebf5b2...cfac27a. Read the comment docs.

@CasperWA CasperWA changed the title [BLOCKED] Add database page limit Add database page limit Jan 19, 2020
optimade/server/config.py Outdated Show resolved Hide resolved
optimade/server/entry_collections.py Outdated Show resolved Hide resolved
)
if limit == 0:
limit = self.page_limit
limit = CONFIG.page_limit
Copy link
Member

Choose a reason for hiding this comment

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

is this necessary?
what if limit < 0?

If people explicitly request 0 entries, I'd say they should get 0 entries

Copy link
Member Author

@CasperWA CasperWA Jan 20, 2020

Choose a reason for hiding this comment

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

what if limit < 0?

This is handled by the QueryParams, i.e., all query parameter of page_* are NonNegativeInt types.

Copy link
Member Author

Choose a reason for hiding this comment

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

But I guess we could put in another check, although it shouldn't be necessary?

Update handling of `page_limit` in `_parse_params()`.
@CasperWA CasperWA requested a review from ltalirz January 20, 2020 12:01
Copy link
Member

@ltalirz ltalirz 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 to me!

@CasperWA CasperWA merged commit 0abf9d8 into master Jan 20, 2020
@CasperWA CasperWA deleted the add_db_page_limit branch January 20, 2020 12:10
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.

None yet

2 participants