feat(v1.1): items 7-8 — fresh counter pill + loud 'No more new bikes!' empty state

Item 7: /api/stats gains fresh (actives with no swipe row — the deck's
new-pool predicate verbatim); the header pill reads 'N live · M fresh'
(new badge unchanged); old APIs without fresh render no segment.

Item 8: sections.pool_counts() answers can-the-forge-serve-anything from
the composer's own candidate SQLs (stock answer, LAST_TWO not applied)
and rides every section_state body. The FE adds #empty2 ('No more new
bikes!' + 08:30 line + undo note): shown whenever the pile/buffer drain
and pool is 0/0/0 (report masked), on a zero-item dry forge too; undo
hides it; legacy .empty untouched. UpdateUI repaints the caption per
hydrate; the stats key-set selfcheck gains fresh.
This commit is contained in:
Torres
2026-11-13 13:42:08 -04:00
parent 0d2e5a592f
commit a1455aade4
4 changed files with 155 additions and 3 deletions

View File

@@ -442,6 +442,20 @@ def section_decided_ids(conn, section):
WHERE e.section_id = ?""", (section['id'],))}
def pool_counts(conn):
"""Stock answer to \"can the forge serve anything?\" — fresh / eligible
returns / wildcards candidate counts, each from the composer's own
candidate SQL. The per-section LAST_TWO exclusion inside compose_section
is deliberately NOT applied here: the answer is about stock, not about
what one batch will pick (item 8)."""
def _count(sql):
return conn.execute(
'SELECT COUNT(*) AS n FROM (%s)' % sql).fetchone()['n']
return {'fresh': _count(NEW_POOL_SQL),
'returns': _count(RETURNS_SQL),
'wildcards': _count(WILDCARD_SQL)}
def section_counts(conn, section):
"""Per-action counts + second-look / wildcard engagement for this
section (events stamped with this section_id only)."""