Skip to content

Conversation

@henry-r18
Copy link
Contributor

@henry-r18 henry-r18 commented Oct 23, 2025

Implements SYS-2069

Acceptance criteria

  • Add a /records/ endpoint which allows retrieval of all SheetImport records as JSON, the same format as the specific /records/<record_id>
    • This endpoint also requires basic authentication.
  • Records are retrieved in ascending numerical order by record_id
  • The endpoint accepts the following parameters:
    • offset: Offset of the results returned. Optional. Default value: 0, which means that the first results will be returned
    • limit: 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 work
  • The endpoint uses the following response format: JSON, with two top-level elements:
    • records: A list of dictionaries, 1 for each record in the specified range
    • total_records: An integer with the total number of records which will be retrieved, so the caller knows how to manage offset and limit to get all records

Description

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_dict utility, which handles serialization and joining of some data from objects other than SheetImport. 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.

@henry-r18 henry-r18 marked this pull request as ready for review October 23, 2025 20:21
@henry-r18 henry-r18 requested a review from akohler October 23, 2025 20:22
Copy link
Member

@akohler akohler left a comment

Choose a reason for hiding this comment

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

@henry-r18 This is great! The code does what's needed, simply and efficiently. Tests are relevant and all pass. I tested via curl requests and by writing a simple python program to retrieve all records in batches of 1000. Everything I saw worked as expected, and performance against my local system was very good.

Please add release notes and a version bump for deployment, then I'll merge and we'll try it in production.

Thanks --Andy

@henry-r18
Copy link
Contributor Author

@akohler, just pushed the version bump and release note—thanks!

@henry-r18 henry-r18 requested a review from akohler October 23, 2025 23:04
Copy link
Member

@akohler akohler left a comment

Choose a reason for hiding this comment

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

Merging now.
@ztucker4 FYI

@akohler akohler merged commit cae87c4 into main Oct 23, 2025
1 check passed
@akohler akohler deleted the SYS-2069/get_all_records_endpoint branch October 23, 2025 23:20
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.

2 participants