One SQL roll-up, and a WCAG 2.2 AA baseline that has to survive photocopying
Moving a dashboard roll-up into a single SQL statement so its figures cannot contradict each other, a defect in which the headline "In stock" figure counted five statuses while its own link asked for one, and an accessibility pass whose lasting rule is that status is never conveyed by colour alone.
What was done
The dashboard had grown into a page that fired many queries and assembled the answer in JavaScript, so its figures were computed at slightly different moments and could disagree with each other. The roll-up moved into single SQL statements using FILTER clauses over one scan, which made it faster and, more to the point, self-consistent. The defect worth recording was found by clicking: the headline "In stock" tile counted five stock statuses while the list it linked to filtered on 'in_stock' alone — a status almost nothing in a real warehouse has, since it is only written when an admin undoes a sale. Neither half was wrong on its own; they answered different questions while appearing to answer the same one. The three status sets were lifted into one module that both the dashboard and the assets register import. The same day closed a WCAG 2.2 AA audit, whose lasting rule is that status is never conveyed by colour alone, because erasure certificates and lock statuses get printed and photocopied.
BEFORE
"In stock" tile --counts--> 5 statuses (in_stock,
received, audited,
awaiting_audit, returned)
| the operator clicks the number
v
assets list --filters--> stock_status = 'in_stock'
=> a large number that opens a nearly empty list
AFTER
one module: GONE / AVAILABLE / COMMITTED
| |
tile counts AVAILABLE link filters AVAILABLE
\________ one definition, imported by bothThe tile and its own link asked different questions; one shared definition is what stops that.
Status
Shipped, 20 August 2026.
The dashboard
one operational roll-up, computed in SQL.
The dashboard had grown into a page that issued many queries and assembled the answer in JavaScript. Moving the roll-up into one SQL statement made it both faster and — more importantly — consistent: figures computed in separate queries at slightly different moments disagree with each other, and a dashboard whose numbers contradict each other is worse than no dashboard.
an operational control centre. Rebuilt around what somebody running the floor needs to decide today, rather than a set of totals.
The defect worth recording
"In stock": the figure counted five statuses, the link asked for one.
The headline number totalled five stock statuses. Clicking it navigated to a filtered list asking for one. The user saw a number, clicked it, and got a much shorter list with no explanation.
Neither the number nor the list was wrong on its own. The defect was that two parts of one page answered different questions while appearing to answer the same one — the same shape as the reports filter bug in July, and one that only shows up when somebody actually clicks.
The accessibility pass closed out a WCAG 2.2 AA audit. The commits around it are the
substance:
- **** — lighter field borders, and the trade-off written
down. Then corrected to
#c4c4c4when the lighter value failed contrast, and the token stopped being used to paint page furniture it was never meant for. - **** — pallet grids and the repairs log moved to one shared gridline instead of a box per cell. Fewer borders, better contrast where it counts.
- **** — three field treatments, each matched to what the control actually is, rather than one style stretched over inputs, selects and read-only values.
- **** — outline buttons brought to 3:1, and the tokens renamed
after what they do rather than what colour they are. A token called
grey-300invites use anywhere; one calledfield-borderdoes not.
Why it matters
This work established a baseline the whole app is held to: status is never conveyed by colour alone, and a printed or greyscale copy of any page has to read identically. The device-lock section written in September states that rule in its own comments and pairs every colour with a word.
That matters commercially, not just ethically — an erasure certificate and a lock status get printed, faxed and photocopied.
What was deliberately not built
No accessibility overlay or widget. The markup and the contrast were fixed.
Open questions
None outstanding. The August redesign series (#15–#45) extended the visual system to every page.
The code
One statement, one scan: the finance tiles are computed together so they cannot contradict each other.
SELECT
COALESCE(SUM(unit_cost) FILTER (WHERE a.stock_status <> ALL($1)), 0)
AS stock_value, -- $1 = GONE, the shared status list
COALESCE(SUM(a.sale_price) FILTER (WHERE a.stock_status
IN ('sold','shipped')), 0) AS revenue,
COALESCE(SUM(unit_cost) FILTER (WHERE a.stock_status
IN ('sold','shipped')), 0) AS cost_of_sold,
COUNT(*) FILTER (WHERE a.stock_status IN ('sold','shipped')) AS sold,
COUNT(*) AS total
FROM assets a
-- unit_cost is the per-unit cost basis: the unit's own purchase cost when
-- set, else an even split of its lot's total over EVERY unit in the lot,
-- sold ones included. Lot joins and the ownership scope clause elided.apps/api/src/dashboard/dashboard.service.ts — an excerpt, trimmed to the technique it illustrates.
Not shown. The ownership scope clause and its parameters are elided from the excerpt — that is the per-user visibility control. Also left out: the per-tile drill-down links, the attention-list thresholds, and the colour tokens themselves, which are a design system rather than an idea.
A published copy. Commit references and internal identifiers have been removed and the operator is not named; the engineering, the counts and the stated limits are unchanged.