Avoid fetching unnecessary data when posting review requests.

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

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.

Summary ID
Avoid fetching unnecessary data when posting review requests.
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). Testing Done: Posted changes and looked carefully at the --debug output. Verified that we were no longer doing unnecessary or unnecessarily heavy API requests.
9431bc75cae2142365e7c6d7344d959d7a59ca6e
Description From Last Updated

Can we add Version Added here?

chipx86chipx86
chipx86
  1. 
      
  2. rbtools/commands/post.py (Diff revision 1)
     
     
     
     
     
     
    Show all issues

    Can we add Version Added here?

  3. 
      
david
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-5.x (40069e0)
Loading...