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:
10
app/api.py
10
app/api.py
@@ -238,6 +238,14 @@ def create_app(db_path, img_dir, state_dir=None):
|
||||
live = conn.execute(
|
||||
"SELECT COUNT(*) AS n FROM listings WHERE status='active'"
|
||||
).fetchone()['n']
|
||||
# item 7: fresh = active with no swipe row (the deck's new-pool
|
||||
# predicate, verbatim). A swipe of ANY age removes freshness.
|
||||
fresh = conn.execute(
|
||||
"SELECT COUNT(*) AS n FROM listings l"
|
||||
" WHERE l.status='active'"
|
||||
" AND NOT EXISTS (SELECT 1 FROM swipes s"
|
||||
" WHERE s.listing_id = l.id)"
|
||||
).fetchone()['n']
|
||||
badge = get_pref(conn, 'badge_seen_at') or ''
|
||||
new = conn.execute(
|
||||
"SELECT COUNT(*) AS n FROM listings"
|
||||
@@ -253,6 +261,7 @@ def create_app(db_path, img_dir, state_dir=None):
|
||||
' ORDER BY id DESC LIMIT 1').fetchone()
|
||||
return {
|
||||
'live': live,
|
||||
'fresh': fresh,
|
||||
'new': new,
|
||||
'likes': per['like'],
|
||||
'maybes': per['maybe'],
|
||||
@@ -463,6 +472,7 @@ def create_app(db_path, img_dir, state_dir=None):
|
||||
data['items'] = items
|
||||
data['mode'] = mode
|
||||
data['recipe'] = (json.loads(sec['recipe']) if sec['recipe'] else {})
|
||||
data['pool'] = secmod.pool_counts(conn)
|
||||
data['prefs'] = {'rubric_debug': get_pref(conn, 'rubric_debug', 'off')}
|
||||
data['can_forge'] = (mode != 'strict'
|
||||
or secmod.fresh_profile_exists(conn, sec))
|
||||
|
||||
Reference in New Issue
Block a user