Preemptively evaluate values_list queries during counter field updates.

Review Request #12700 — Created Oct. 27, 2022 and submitted

Information

Review Board
release-6.x

Reviewers

We had a couple places when updating review request counters where we'd
fetch a values_list of PKs, and then pass that directly into future
queries, which would end up evaluating them as subqueries. This has two
problems--first, we end up running the subqueries multiple times, and
second, it's impossible to use assertQueries.

This change fixes those up. There are still cases where we have
subqueries that are added by Django's QuerySet.update() method, but
this handles the stuff in our own code.

Verified with assertQueries usage that we no longer had subqueries for
these.

Summary ID
Preemptively evaluate values_list queries during counter field updates.
We had a couple places when updating review request counters where we'd fetch a `values_list` of PKs, and then pass that directly into future queries, which would end up evaluating them as subqueries. This has two problems--first, we end up running the subqueries multiple times, and second, it's impossible to use `assertQueries`. This change fixes those up. There are still cases where we have subqueries that are added by Django's `QuerySet.update()` method, but this handles the stuff in our own code. Testing Done: Verified with `assertQueries` usage that we no longer had subqueries for these.
8a471f5f26419dd5f7d7be638a1d35ece948d9f9
chipx86
  1. Ship It!
  2. 
      
david
Review request changed
Status:
Completed
Change Summary:
Pushed to release-6.x (9bbd446)