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

Add a new way to query all users #151

Open
dbrezack opened this issue Nov 30, 2023 · 0 comments
Open

Add a new way to query all users #151

dbrezack opened this issue Nov 30, 2023 · 0 comments

Comments

@dbrezack
Copy link

Problem explanation

Zendesk ticket: 43044
query_channels possible infinite loop by always returning results over 1000
eg Asking for offset: 1000000 will return users even when only 2000 users may exist in the system.

https://support.getstream.io/hc/en-us/articles/4414446580119-Querying-for-users-channels-past-the-offset-1000-limit-Chat

I would suggest that the library implement an easy way to query all users with offsets greater than 1000, maybe a python iterable.

Steps to reproduce

I'm well aware this code is not very clean but it does show the issue. Since query channels will always return items in the array you don't know when to stop.

channels = []
offset = 0
limit = max_limit_to_fetch_channels
channels_fetched_count = limit
while channels_fetched_count > 0 or channels_fetched_count == limit:
    channels_fetched = query_channels(
        filter_conditions=......,
        sort={"last_message_at": -1},
        message_limit=1,
        channel_limit=limit,
        offset=offset,
    )
    channels.extend(channels_fetched)
    offset += limit
    channels_fetched_count = len(channels_fetched)

Environment info

Library version: stream-chat==4.8.0

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

No branches or pull requests

1 participant