1. Derive status in SQL, don’t store it twice
A record’s status usually depends on what has happened to it: submitted, waiting for the customer, reviewed with a decision. Rather than updating astatus column from several places, derive it when reading, from the record and its latest result:
queries/records_list.yaml
LEFT JOIN LATERAL … LIMIT 1takes the latest result per record, so re-running a review simply adds a row and the status follows.{{rls}}applies each user’s data permissions.- Callers can narrow the list with a filter, for example
$filter=status eq 'AWAITING_REVIEW'.
2. One query for the whole dashboard
A dashboard is one dynamic query with several result sets: one round trip, and every number in one place. The SQL below is abbreviated where marked…; reuse the status derivation from step 1.
queries/reviews_dashboard.yaml
force_fetch=1, or rely on the 2-minute cache for busy dashboards.
3. What to show
Keep statuses consistent everywhere: the same name, colour and label in the list, the dashboard and the record page.
4. Lists
For the record list, runrecords_list with limit/offset for paging and a $filter for the status tabs. Link each row to the record’s page, where the decision, the evidence, an audit timeline and a chat assistant sit together.

