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

Limit number of fetched conversations in the API #954

Merged
merged 3 commits into from Mar 25, 2024
Merged

Conversation

nsarrazin
Copy link
Collaborator

We were missing the same limit that we use in the load function of the web app.

@nsarrazin
Copy link
Collaborator Author

cc @alak, we had a limit in the load function for the web app to avoid loading too many conversations at once, ported it over to the API endpoint with added pagination 😄

Copy link
Collaborator

@alak alak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

I'll update my side today.

Comment on lines 19 to 20
.skip(300 * p)
.limit(300)
Copy link
Collaborator

@mishig25 mishig25 Mar 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.skip(300 * p)
.limit(300)
.skip(NUM_PER_PAGE * p)
.limit(NUM_PER_PAGE)

and declaring const NUM_PER_PAGE = 300; above would be more robust since skip & limit should be tied with one another through a variable

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make it an env var? So it's also tied to the one in the load function ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

up to you. For me, it is fine as long as it is a variable here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

@nsarrazin nsarrazin merged commit e9ad67e into main Mar 25, 2024
3 checks passed
@nsarrazin nsarrazin deleted the api/limit_convs branch March 25, 2024 14:41
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

Successfully merging this pull request may close these issues.

None yet

3 participants