The grants listing query is written twice, and only its delivery state is checked for drift #189

Closed
opened 2026-10-06 21:25:46 +00:00 by cgalo5758 · 1 comment
Owner

docs/models/entitlements.md says the grants index and an organization's grants table read one query. In internal/entitlements/queries/grants.sql, ListGrantsWithDeliveryPage copies ListGrantsWithDelivery (about two hundred lines), adds search, a state filter and paging, and repeats the state CASE in HAVING. toDeliveryRows (internal/server/operator_partials.go) converts between their row types. Tests compare only the state, the main one without on hold; nothing compares Manage, the waiting reason or the will-not-resume flag.

Done when: one query takes organization, search, state and page as optional arguments, computes the state once, returns one row type, and the model page matches.

`docs/models/entitlements.md` says the grants index and an organization's grants table read one query. In `internal/entitlements/queries/grants.sql`, `ListGrantsWithDeliveryPage` copies `ListGrantsWithDelivery` (about two hundred lines), adds search, a state filter and paging, and repeats the state CASE in HAVING. `toDeliveryRows` (`internal/server/operator_partials.go`) converts between their row types. Tests compare only the state, the main one without on hold; nothing compares Manage, the waiting reason or the will-not-resume flag. Done when: one query takes organization, search, state and page as optional arguments, computes the state once, returns one row type, and the model page matches.
cgalo5758 added this to the Public launch milestone 2026-10-06 21:25:46 +00:00
cgalo5758 added the
kind
debt
area/entitlementsarea/operator-ui
labels 2026-10-06 21:25:46 +00:00
Author
Owner

ListGrantsWithDelivery is now the one grants listing query (e68493ea). Organization, search, state and page are optional arguments; the delivery state is computed once, in a CTE, and the outer statement filters on it; the grants index and the organization's grants table read the one row type. ListGrantsWithDeliveryPage and toDeliveryRows are gone, and docs/models/entitlements.md and docs/operator-ux-conventions.md describe the one query.

TestGrantsListingRowsGolden holds each grant's row as a golden and, in its drift subtest, compares all 25 columns of every grant between the organization call and the search call, Manage, the waiting reason and the will-not-resume flag included. Both pages' output was unchanged by the merge.

Grants written in one transaction share created_at, so the listing now breaks that tie by grant id, the later-written grant first (f725927e).

`ListGrantsWithDelivery` is now the one grants listing query (e68493ea). Organization, search, state and page are optional arguments; the delivery state is computed once, in a CTE, and the outer statement filters on it; the grants index and the organization's grants table read the one row type. `ListGrantsWithDeliveryPage` and `toDeliveryRows` are gone, and `docs/models/entitlements.md` and `docs/operator-ux-conventions.md` describe the one query. `TestGrantsListingRowsGolden` holds each grant's row as a golden and, in its `drift` subtest, compares all 25 columns of every grant between the organization call and the search call, Manage, the waiting reason and the will-not-resume flag included. Both pages' output was unchanged by the merge. Grants written in one transaction share `created_at`, so the listing now breaks that tie by grant id, the later-written grant first (f725927e).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: wiki-cafe/member-console#189