-
Notifications
You must be signed in to change notification settings - Fork 1
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
Implement backend pagination for GET /listings #133
Conversation
Also, change the title of the PR to imperative and remove your username, as if it were the first line of the CL. |
Thanks for the comments @willrlin ! I closed the conversations that I felt were resolved, and left the ones that you may have follow-up on open - let me know? And I changed the PR title, thanks for catching that! |
…ervices resilient to this new default
…CityOfDetroit/bloom into aeschneider-backend-listings-pagination
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I believe that whenever the backend api changes, we need to regenerate the client with |
I fixed the errors with the public and partner portals, with the default values they display all the listings as they did before. I also ran the client library codegen, which generated some changes I expected and others I didn't expect and can't really explain. PTAL at the newest commit, the issues were with some objects being "undefined", but I'm pretty unfamiliar with typescript so I'm pretty skeptical of the code I wrote. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems fine to me. As for the codegen, hopefully it was just a bit out of date. Maybe we should set a presubmit check to ensure that the generated version matches the PR version?
Issue
Addresses #56
Description
This change changes the parameters and return type for
GET /listings
such that results are paginated. The parameters now includepage
andlimit
fields, and the returned object includes both an array of Listings and metadata about e.g. which page of listings this represents, how many total listings there are, how many listings per page, etc.The pagination implementation uses
skip
andtake
when building the SQL query, and those correspond to SQL'sOFFSET
andLIMIT
, respectively.typeorm
actually sends two queries as a result: a first to ask for all the IDs of listings that are in the specified range, and a second to get all of the data (including all of the data inJOIN
ed tables). (And, this change adds a thirdSELECT COUNT(*) FROM listings;
query in order to populate the pagination metadata, but that should be fast.) The hope is that, although this change means more SQL queries to the database, the overall time to retrieve listing data is faster since we don't have to retrieve all of theJOIN
ed data in a single query.This change also adds a couple tests and fixes a couple places in the frontend so that they understand the new paginated-listings return type.
Type of change
How Can This Be Tested/Reviewed?
Also, if you run the code locally and point your browser to
localhost:3100/listings
, you should be able to see the new paginated listings result.Checklist: