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

API counts for paginated routes #3899

Merged
merged 8 commits into from
Mar 28, 2019
Merged

API counts for paginated routes #3899

merged 8 commits into from
Mar 28, 2019

Conversation

youri-k
Copy link
Contributor

@youri-k youri-k commented Mar 14, 2019

Steps to test:

  • make an api request to a paginated route
  • look for X-Total-Count in response to show how many entries were found

Issues:


@youri-k youri-k requested a review from fm3 March 14, 2019 17:13
Copy link
Member

@fm3 fm3 left a comment

Choose a reason for hiding this comment

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

Thanks for this PR! This works well :-) However, I have a couple of thoughts:

  • Performance: while counting the entries in the database uses way less resources than actually fetching them, it is still fairly slow for large collections. This is why I’d suggest to modify the routes to include an optional includeTotalCount boolean parameter defaulting to false. Only when this is set to true, run the count queries
  • maintainability: I noticed some code duplication between the methods that fetch and the methods that count the records. Maybe some of their parts could be extracted to reusable methods (e.g. stateQuery for the annotation list)

@youri-k youri-k self-assigned this Mar 20, 2019
@youri-k youri-k merged commit 428769e into master Mar 28, 2019
@normanrz normanrz deleted the add-api-counts branch August 12, 2019 09:47
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.

next to paginated API requests: provide counts
2 participants