Phase 8: Project Management, find bar, presence and motion
ci / frontend (push) Successful in 43s
ci / server (push) Successful in 11m6s
ci / image (push) Successful in 38s
ci / e2e (push) Successful in 3m55s

The Project Management screen (/pm, view only) with Overview, Projects & units, Bottlenecks & aging, Hours vs target,
Quality & issues and Find jobs, the period picker, health per unit and per project, drill down, Excel (CSV) per table
and for all, and the PESCO production status report PDF with the controlled-copy stamp; every export logged as
"report exported". The find bar on every home screen: the full search set, the dropdowns, quick flags with Mine, the
flag kinds, Board and List with sorts, filters saved per browser; every filter applied by the server on the list and
the boards, with facets. Presence in packets with role, lock and revoke drop; the motion switch with reduced motion
honoured, card glides, glow and count-up; Back restores the scroll spot; sheet placement and the iPad layout pass. The
data book compared page by page with the old build and six layout differences fixed. Tests for the PM aggregates,
search, filters, presence and exports; Playwright scenarios for the PM screen, the find bar and presence at desktop and
iPad viewports. Docs updated; PLAN.md questions 38 to 42.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
This commit is contained in:
2026-10-18 15:08:34 -06:00
co-authored by Claude Fable 5.1
parent 904437153d
commit 6b6db0230f
90 changed files with 10450 additions and 563 deletions
+35 -8
View File
@@ -11,7 +11,7 @@ from typing import Any
from .. import policy
from ..text import LIMITS
from . import itp, packets, qcdocs
from . import itp, packets, qcdocs, search
A = policy.Action
@@ -128,6 +128,8 @@ LAST_SQL = (
" WHERE h.packet_id = p.id ORDER BY h.id DESC LIMIT 1) h ON true"
" WHERE p.removed_at IS NULL AND p.status::text = ANY(%s) AND h.result = %s"
)
WAITING_SQL = "SELECT count(*) FROM packets p WHERE p.removed_at IS NULL AND p.status = 'qc'"
BOARD_LIMIT = 5000
COUNT_SQL = (
"SELECT count(DISTINCT l.packet_id) FROM packet_log l JOIN packets p ON p.id = l.packet_id"
" WHERE l.at > now() - interval '7 days' AND l.action LIKE %s AND p.removed_at IS NULL"
@@ -147,29 +149,54 @@ def _count_7d(conn: Any, prefix: str, where: str, params: list[Any]) -> int:
def home(
conn: Any, pp: policy.Principal, *, project_id: int | None = None, unit_id: int | None = None
conn: Any,
pp: policy.Principal,
*,
project_id: int | None = None,
unit_id: int | None = None,
filters: Mapping[str, Any] | None = None,
) -> dict[str, Any]:
"""GET /api/qc/home: the KPIs, the three boards and the active project folders."""
filters: dict[str, Any] = {"project_id": project_id, "unit_id": unit_id}
"""GET /api/qc/home: the KPIs, the three boards and the active project folders. `filters` (the find bar's)
narrow the cards of the three boards; the KPIs follow the project and unit only."""
scope: dict[str, Any] = {"project_id": project_id, "unit_id": unit_id}
narrow = search.board_filters(filters or {})
narrow.update(scope)
ready = sorted(
packets.list_cards(conn, pp, {**filters, "status": "qc"}),
packets.list_cards(conn, pp, {**narrow, "status": "qc", "limit": BOARD_LIMIT}),
key=lambda c: (c["status_at"], c["id"]),
)
where, params = _scope_where(project_id, unit_id)
acc_ids = _ids_with_last(conn, ("complete", "filed"), "accepted", where, params)[:ACCEPTED_ON_BOARD]
acc_all = _ids_with_last(conn, ("complete", "filed"), "accepted", where, params)
if search.narrowing(narrow) and acc_all:
# The newest accepted packets that match the find bar (a light pass, no `can`), then the board's eight.
hits = {
c["id"]
for c in packets.list_cards(conn, pp, {**narrow, "ids": acc_all, "lite": True, "limit": BOARD_LIMIT})
}
acc_all = [i for i in acc_all if i in hits]
acc_ids = acc_all[:ACCEPTED_ON_BOARD]
rej_ids = _ids_with_last(conn, ("review",), "rejected", where, params)
by_id = {c["id"]: c for c in packets.list_cards(conn, pp, {"ids": acc_ids + rej_ids})} if acc_ids or rej_ids else {}
by_id: dict[Any, dict[str, Any]] = {}
if acc_ids or rej_ids:
by_id = {
c["id"]: c for c in packets.list_cards(conn, pp, {**narrow, "ids": acc_ids + rej_ids, "limit": BOARD_LIMIT})
}
accepted = [by_id[i] for i in acc_ids if i in by_id]
rejected = [by_id[i] for i in rej_ids if i in by_id]
_add_qc(conn, ready + accepted + rejected)
waiting = len(ready)
if search.narrowing(filters or {}):
row = conn.execute(WAITING_SQL + where, params).fetchone() # where: fixed fragments from _scope_where
waiting = int(row[0] or 0)
return {
"kpis": {
"waiting": len(ready),
"waiting": waiting,
"accepted_7d": _count_7d(conn, "Q.C. accepted", where, params),
"rejected_7d": _count_7d(conn, "Q.C. rejected", where, params),
},
"columns": {"ready": ready, "accepted": accepted, "rejected": rejected},
"folders": qcdocs.folders(conn, "active"),
"facets": search.facets(conn, project_id=project_id, unit_id=unit_id),
}