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

feat(pagination): avoid fetching when has_more: false #693

Merged
merged 1 commit into from
Feb 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/lithic/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ def _get_page_items(self) -> List[_T]:
return []
return data

@override
def has_next_page(self) -> bool:
has_more = self.has_more
return has_more and super().has_next_page()

@override
def next_page_info(self) -> Optional[PageInfo]:
is_forwards = not self._options.params.get("ending_before", False)
Expand Down Expand Up @@ -61,6 +66,11 @@ def _get_page_items(self) -> List[_T]:
return []
return data

@override
def has_next_page(self) -> bool:
has_more = self.has_more
return has_more and super().has_next_page()

@override
def next_page_info(self) -> Optional[PageInfo]:
is_forwards = not self._options.params.get("ending_before", False)
Expand Down Expand Up @@ -96,6 +106,11 @@ def _get_page_items(self) -> List[_T]:
return []
return data

@override
def has_next_page(self) -> bool:
has_more = self.has_more
return has_more and super().has_next_page()

@override
def next_page_info(self) -> None:
"""
Expand All @@ -116,6 +131,11 @@ def _get_page_items(self) -> List[_T]:
return []
return data

@override
def has_next_page(self) -> bool:
has_more = self.has_more
return has_more and super().has_next_page()

@override
def next_page_info(self) -> None:
"""
Expand Down