Introduce new file attachment and screenshot counters for review requests.
Review Request #9242 — Created Oct. 3, 2017 and submitted
When viewing or publishing review requests, we perform a series of
lookups on the file attachments and screenshots (active and inactive) on
the review request and on the draft. This can be up to 8 queries that
we don't really want in most cases (screenshots are never used anymore,
but remain supported for old review requests), but we had no good way of
choosing whether to perform queries for them.
ReviewRequestDraftnow have new
RelationCounterFieldsthat track how many active and inactive file
attachments and screenshots there are. This allows code to simply check
the populated counters instead of performing a series of queries,
improving performance across the product and all but guaranteeing that
we won't look up screenshots anymore.
Unit tests pass.
Checked existing drafts and review requests and saw that the counters
were populated to the correct values.
Created a new draft and saw that it had the correct counters from the
Uploaded new file attachments and saw that the draft's counters were
Deleted a file attachment and saw that the draft's counters were updated
Published the draft. Saw that the review request's counters were updated
get_file_attachmentsto return a list again.
Revision 2 (+567 -122)
Checks run (2 succeeded)