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

Terminate on empty page #338

Merged
merged 3 commits into from
Jan 20, 2023
Merged

Terminate on empty page #338

merged 3 commits into from
Jan 20, 2023

Conversation

gadomski
Copy link
Member

@gadomski gadomski commented Oct 21, 2022

Related Issue(s):

Description:

Terminate pagination on an empty page.

PR Checklist:

  • Code is formatted
  • Tests pass
  • Changes are added to the CHANGELOG

@gadomski gadomski requested a review from philvarner October 21, 2022 21:01
@gadomski gadomski force-pushed the issues/334-terminate-on-empty-page branch from 07e815c to d52f2ce Compare October 21, 2022 21:11
@codecov-commenter
Copy link

codecov-commenter commented Nov 28, 2022

Codecov Report

Base: 85.18% // Head: 85.60% // Increases project coverage by +0.41% 🎉

Coverage data is based on head (6b97e36) compared to base (e45c68d).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #338      +/-   ##
==========================================
+ Coverage   85.18%   85.60%   +0.41%     
==========================================
  Files          11       11              
  Lines         790      792       +2     
==========================================
+ Hits          673      678       +5     
+ Misses        117      114       -3     
Impacted Files Coverage Δ
pystac_client/item_search.py 92.57% <100.00%> (ø)
pystac_client/stac_api_io.py 89.18% <100.00%> (+2.95%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@gadomski gadomski force-pushed the issues/334-terminate-on-empty-page branch from bdce856 to 448b67a Compare November 28, 2022 22:01
@gadomski gadomski added this to the 0.5.2 milestone Dec 13, 2022
@gadomski gadomski force-pushed the issues/334-terminate-on-empty-page branch 3 times, most recently from e4c4948 to 2d8d459 Compare December 15, 2022 19:51
@gadomski gadomski marked this pull request as ready for review December 15, 2022 19:52
@gadomski gadomski requested a review from philvarner December 15, 2022 19:52
@gadomski gadomski force-pushed the issues/334-terminate-on-empty-page branch 2 times, most recently from 645b381 to 8b90adb Compare December 15, 2022 20:12
@gadomski gadomski self-assigned this Dec 30, 2022
tests/test_item_search.py Outdated Show resolved Hide resolved
@gadomski gadomski force-pushed the issues/334-terminate-on-empty-page branch from 8b90adb to 3ccafae Compare January 17, 2023 16:19
@gadomski gadomski force-pushed the issues/334-terminate-on-empty-page branch from 3ccafae to fc1df8c Compare January 19, 2023 21:48
@gadomski gadomski requested a review from Geosynopsis January 19, 2023 21:49
@gadomski gadomski force-pushed the issues/334-terminate-on-empty-page branch from fc1df8c to b5bb1ce Compare January 19, 2023 21:50
@gadomski gadomski force-pushed the issues/334-terminate-on-empty-page branch from b5bb1ce to 9e4bfea Compare January 19, 2023 21:51
@gadomski gadomski requested a review from pjhartzell January 20, 2023 10:02
Copy link
Collaborator

@pjhartzell pjhartzell left a comment

Choose a reason for hiding this comment

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

Is it possible that the initial page can have no features and we would want to return None? Or is this moot/handled in other ways?

page = self.read_json(url, method=method, parameters=parameters)
yield page

@gadomski
Copy link
Member Author

Is it possible that the initial page can have no features and we would want to return None?

Yeah, it's a good point, we should return None (to stop iteration) if features is empty on first grab. I'll implement.

@gadomski
Copy link
Member Author

@pjhartzell good catch. I missed the documentation that those pages were used for collection paging as well as item paging. By adding the early short-circuit, I broke of collection fetching tests. I've updated the test suite and the code to handle both item and collection paging.

@gadomski gadomski requested a review from pjhartzell January 20, 2023 18:52
@gadomski gadomski force-pushed the issues/334-terminate-on-empty-page branch from dd084a9 to acb1866 Compare January 20, 2023 18:52
@pjhartzell
Copy link
Collaborator

good catch. I missed the documentation that those pages were used for collection paging as well as item paging. By adding the early short-circuit, I broke of collection fetching tests.

Well, I wasn't thinking about both collection and item paging either. But glad my suggestion broke stuff enough to make that bubble up. 🙂

@gadomski gadomski merged commit 03b847e into main Jan 20, 2023
@gadomski gadomski deleted the issues/334-terminate-on-empty-page branch January 20, 2023 19:35
@gadomski gadomski modified the milestones: 0.5.2, 0.6.0 Jan 27, 2023
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.

Pagination should terminate if it ever gets an empty page from the server
6 participants