Skip to main content
Once records flow through a review workflow, people need to see them: a list with each record’s current status, and a dashboard of the pipeline. This guide builds both from dynamic queries, without a separate reporting system.

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 a status column from several places, derive it when reading, from the record and its latest result:
queries/records_list.yaml
  • LEFT JOIN LATERAL … LIMIT 1 takes 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
Run it once per page load with 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, run records_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.
Dynamic queries return at most 100 rows per result set unless you pass a larger limit. Aggregate in SQL for dashboards rather than fetching rows to count in the browser.