-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Add offset parameter to get_items() for pagination #2811
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,7 +70,9 @@ async def _get_session_id(self) -> str: | |
| async def _clear_session_id(self) -> None: | ||
| self._session_id = None | ||
|
|
||
| async def get_items(self, limit: int | None = None) -> list[TResponseInputItem]: | ||
| async def get_items( | ||
| self, limit: int | None = None, offset: int = 0 | ||
| ) -> list[TResponseInputItem]: | ||
|
Comment on lines
+74
to
+75
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Useful? React with 👍 / 👎. |
||
| session_id = await self._get_session_id() | ||
|
|
||
| session_limit = resolve_session_limit(limit, self.session_settings) | ||
|
|
||
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.
The Redis pagination math passes raw negative indices to
LRANGE; whenoffsetexceeds the list length, Redis normalizes out-of-range indices instead of erroring, so ranges like0, -(offset+1)can still return the oldest element(s) instead of an empty list. That makesget_items(offset>=len(history))return stale data and breaks page boundaries.Useful? React with 👍 / 👎.