SYS-2069: Add API endpoint to get all records serialized as JSON #90
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implements SYS-2069
Acceptance criteria
/records/endpoint which allows retrieval of all SheetImport records as JSON, the same format as the specific/records/<record_id>record_idoffset: Offset of the results returned. Optional. Default value: 0, which means that the first results will be returnedlimit: Limits the number of results. Optional. Default value: 100. Valid values: 0-??? - maybe 250, maybe 500, depends on performance. If even 100 is too slow, decrease the default, but this means we also need to do some performance workrecords: A list of dictionaries, 1 for each record in the specified rangetotal_records: An integer with the total number of records which will be retrieved, so the caller knows how to manageoffsetandlimitto get all recordsDescription
This PR adds an API endpoint to retrieve all records, serialized as JSON via our particular logic, through paginated results. The endpoint takes the form
records/?offset={OFFSET}&limit={LIMIT}, with defaults of 0 and 100 for the two query parameters respectively.The underlying view for this endpoint utilizes our
transform_record_to_dictutility, which handles serialization and joining of some data from objects other thanSheetImport. This seems to work fine performance-wise in my local setup—retrieving 100 records takes ~0.5 seconds, and 10,000 records takes ~6 seconds.Testing
I added 3 tests to cover the criteria that the results be in ascending order by ID and that the limit and offset params work as expected. Total tests now stand at 74.