batches: calculate batch spec diffstats in the database
Created by: LawnGnome
This massively improves performance when previewing batch specs — on a test batch spec locally with +957,887 •298 −0, this takes the time to resolve the diffStat
field from 2-4 seconds to tens of milliseconds. (Remember, this query is refreshed every five seconds, by default, when anyone has the preview page open.)
My thanks to @eseliger for adding the right AuthzQueryConds
magic to make this work, along with the unit tests.
Test plan
Existing unit tests continue to pass, new tests were added (thanks again, Erik!), and I've tested this locally in browser for functionality and with graphql-field-timer
for performance.