Avoid fetching a StatusUpdate per Review on the review request page.

Review Request #14313 — Created Jan. 29, 2025 and updated

Information

Review Board
release-7.1.x

Reviewers

We had code in the review request page that checked for the presence of
the Review.status_update attribute. This in turn triggered a query for
the object on the other end of that relation, regardless of whether it
existed. That led to a useless query per review, especially since we had
already fetched all status updates on the page.

This change adds some pre-processing, creating a map of reviews to
status updates, and utilizes that map instead of performing the
attribute check.

This offers a pretty large savings on most review requests.

Unit tests passed.

Verified in Django Debug Toolbar that the repeated SQL queries for
status updates were no longer present.

Summary ID
Avoid fetching a StatusUpdate per Review on the review request page.
We had code in the review request page that checked for the presence of the `Review.status_update` attribute. This in turn triggered a query for the object on the other end of that relation, regardless of whether it existed. That led to a useless query per review, especially since we had already fetched all status updates on the page. This change adds some pre-processing, creating a map of reviews to status updates, and utilizes that map instead of performing the attribute check. This offers a pretty large savings on most review requests.
9510e1c617706e9c3a0362a8c289fa469e3c75a8
david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Change Summary:

Updated the new review request view unit tests.

Commits:
Summary ID
Avoid fetching a StatusUpdate per Review on the review request page.
We had code in the review request page that checked for the presence of the `Review.status_update` attribute. This in turn triggered a query for the object on the other end of that relation, regardless of whether it existed. That led to a useless query per review, especially since we had already fetched all status updates on the page. This change adds some pre-processing, creating a map of reviews to status updates, and utilizes that map instead of performing the attribute check. This offers a pretty large savings on most review requests.
3a83a7d013d82c2bacd6cb077276162f1d7afba1
Avoid fetching a StatusUpdate per Review on the review request page.
We had code in the review request page that checked for the presence of the `Review.status_update` attribute. This in turn triggered a query for the object on the other end of that relation, regardless of whether it existed. That led to a useless query per review, especially since we had already fetched all status updates on the page. This change adds some pre-processing, creating a map of reviews to status updates, and utilizes that map instead of performing the attribute check. This offers a pretty large savings on most review requests.
9510e1c617706e9c3a0362a8c289fa469e3c75a8

Checks run (2 succeeded)

flake8 passed.
JSHint passed.
maubin
  1. Ship It!
  2.