Skip to content

Commit

Permalink
fix(clients): update browse iterator (generated)
Browse files Browse the repository at this point in the history
algolia/api-clients-automation#4058

Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com>
Co-authored-by: Thomas Raffray <Fluf22@users.noreply.github.com>
  • Loading branch information
algolia-bot and Fluf22 committed Oct 31, 2024
1 parent b1645a0 commit b94e8b0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions algoliasearch/search/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ async def browse_objects(
"""
Helper: Iterate on the `browse` method of the client to allow aggregating objects of an index.
"""
browse_params.hits_per_page = browse_params.hits_per_page or 1000

async def _func(_prev: Optional[BrowseResponse]) -> BrowseResponse:
if _prev is not None and _prev.cursor is not None:
Expand Down Expand Up @@ -392,7 +393,7 @@ async def _func(_prev: Optional[SearchRulesResponse]) -> SearchRulesResponse:

return await create_iterable(
func=_func,
validate=lambda _resp: _resp.nb_hits < hits_per_page,
validate=lambda _resp: len(_resp.hits) < hits_per_page,
aggregator=aggregator,
)

Expand Down Expand Up @@ -427,7 +428,7 @@ async def _func(

return await create_iterable(
func=_func,
validate=lambda _resp: _resp.nb_hits < hits_per_page,
validate=lambda _resp: len(_resp.hits) < hits_per_page,
aggregator=aggregator,
)

Expand Down Expand Up @@ -5362,6 +5363,7 @@ def browse_objects(
"""
Helper: Iterate on the `browse` method of the client to allow aggregating objects of an index.
"""
browse_params.hits_per_page = browse_params.hits_per_page or 1000

def _func(_prev: Optional[BrowseResponse]) -> BrowseResponse:
if _prev is not None and _prev.cursor is not None:
Expand Down Expand Up @@ -5403,7 +5405,7 @@ def _func(_prev: Optional[SearchRulesResponse]) -> SearchRulesResponse:

return create_iterable_sync(
func=_func,
validate=lambda _resp: _resp.nb_hits < hits_per_page,
validate=lambda _resp: len(_resp.hits) < hits_per_page,
aggregator=aggregator,
)

Expand Down Expand Up @@ -5436,7 +5438,7 @@ def _func(_prev: Optional[SearchSynonymsResponse]) -> SearchSynonymsResponse:

return create_iterable_sync(
func=_func,
validate=lambda _resp: _resp.nb_hits < hits_per_page,
validate=lambda _resp: len(_resp.hits) < hits_per_page,
aggregator=aggregator,
)

Expand Down

0 comments on commit b94e8b0

Please sign in to comment.