Skip to content

Commit 7dc7374

Browse files
committed
bugfix/notion fix pagination in BlocksChildrenEndpoint and DatabasesEndpoint
1 parent 6fc428f commit 7dc7374

File tree

1 file changed

+6
-4
lines changed
  • unstructured_ingest/connector/notion

1 file changed

+6
-4
lines changed

unstructured_ingest/connector/notion/client.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,12 @@ def iterate_list(
7878
block_id: str,
7979
**kwargs: Any,
8080
) -> Generator[List[Block], None, None]:
81+
next_cursor = None
8182
while True:
8283
response: dict = (
83-
self.retry_handler(super().list, block_id=block_id, **kwargs)
84+
self.retry_handler(super().list, block_id=block_id, start_cursor=next_cursor, **kwargs)
8485
if self.retry_handler
85-
else super().list(block_id=block_id, **kwargs)
86+
else super().list(block_id=block_id, start_cursor=next_cursor, **kwargs)
8687
) # type: ignore
8788
child_blocks = [Block.from_dict(data=b) for b in response.pop("results", [])]
8889
yield child_blocks
@@ -149,11 +150,12 @@ def query(self, database_id: str, **kwargs: Any) -> Tuple[List[Page], dict]:
149150
return pages, resp
150151

151152
def iterate_query(self, database_id: str, **kwargs: Any) -> Generator[List[Page], None, None]:
153+
next_cursor = None
152154
while True:
153155
response: dict = (
154-
self.retry_handler(super().query, database_id=database_id, **kwargs)
156+
self.retry_handler(super().query, database_id=database_id, start_cursor=next_cursor, **kwargs)
155157
if (self.retry_handler)
156-
else (super().query(database_id=database_id, **kwargs))
158+
else (super().query(database_id=database_id, start_cursor=next_cursor, **kwargs))
157159
) # type: ignore
158160
pages = [Page.from_dict(data=p) for p in response.pop("results", [])]
159161
for p in pages:

0 commit comments

Comments
 (0)