Avoid fetching unnecessary data when posting review requests.

Review Request #13785 — Created April 24, 2024 and submitted — Latest diff uploaded

Information

RBTools
release-5.x

Reviewers

The way the RBTools Python API works, it's annoyingly easy to make GET
requests to list resources when we don't actually care about the
existing data, we just want an instance of the list resource in order to
to do POST operations.

This change fixes rbt post to minimize this in two big cases:
- We were fetching the review request list when creating a new review
request. We had only-fields= on this request, so it wasn't actually
serializing very much data, but it would still query and return a list
of up to 25 review requests.
- We were fetching up to 25 diff file attachments when we wanted to
upload binary files, including all of their data. Moreover, we were
doing this for each binary file we wanted to upload.

With this fix, we now pass max_results=0 to the get operation. This
means we'll get the proper MIME types and links which are used to do
further operations, but we won't fetch any existing data from the
database.

The file attachments resource is now saved once instead of fetching it
for each file.

This also fixes up the DiffFileAttachmentListResource upload method to
use the create link (before it would inherit the ?max-results=0 from
the GET).

Posted changes and looked carefully at the --debug output. Verified that
we were no longer doing unnecessary or unnecessarily heavy API requests.

Commits

Files