snipe/api
pyr0ball 303b4bfb6f feat: SSE live score push for background enrichment (#1)
After a search, the API now returns a session_id. If any trust scores are
partial (pending seller age or category data), the frontend opens a
Server-Sent Events stream to /api/updates/{session_id}. As the background
BTF (account age) and category enrichment threads complete, they re-score
affected listings and push updated TrustScore payloads over SSE. The
frontend patches the trustScores and sellers maps reactively so signal
dots light up without requiring a manual re-search.

Backend:
- _update_queues registry maps session_id -> SimpleQueue (thread-safe bridge)
- _trigger_scraper_enrichment accepts session_id/user_db/query, builds a
  seller->listings map, calls _push_updates() after each enrichment pass
  which re-scores, saves trust scores, and puts events on the queue
- New GET /api/updates/{session_id} SSE endpoint: polls queue every 500ms,
  emits heartbeats every 15s, closes on sentinel None or 90s timeout
- search endpoint generates session_id and returns it in response

Frontend:
- search store adds enriching state and _openUpdates() / closeUpdates()
- On search completion, if partial scores exist, opens EventSource stream
- onmessage: patches trustScores and sellers maps (new Map() to trigger
  Vue reactivity), updates marketPrice if included
- on 'done' event or error: closes stream, enriching = false
- SearchView: pulsing 'Updating scores...' badge in toolbar while enriching
2026-04-05 23:12:27 -07:00
..
__init__.py feat(snipe): FastAPI layer, Playwright+Xvfb scraper, caching, tests 2026-03-25 20:09:30 -07:00
cloud_session.py feat: scammer blocklist, search/listing UI overhaul, tier refactor 2026-04-03 19:08:54 -07:00
ebay_webhook.py feat(snipe): eBay trust scoring MVP — search, filters, enrichment, comps 2026-03-26 23:37:09 -07:00
main.py feat: SSE live score push for background enrichment (#1) 2026-04-05 23:12:27 -07:00