/topbets showed ends 1970-01-01 for some markets. Root cause: the data-api positions feed returns an epoch placeholder 1970-01-01 as the market endDate when the real end date lives on the gamma event, not the market. Fixed by capturing the event end date and falling back to it. Shipped 2026-06-08.

Symptom

/topbets rendered ends 1970-01-01 for certain markets.

Root cause

Epoch placeholder for event-dated markets

The data-api positions feed returns endDate = 1970-01-01 (the Unix epoch placeholder) for markets whose end date lives on the gamma EVENT rather than the market — the market-level endDate is null, and the feed serializes that null as the epoch. So the bug only hit markets that inherit their date from their parent event.

Fix (4 parts)

  1. Capture the event end_date. The category sync now reads the gamma event endDate into a new column pmv2_event_category.end_date (migration 20260608000000). event_tags now returns end_date; upsert_event_category stores it.
  2. Normalize the placeholder to NULL. map_position runs normalize_end_date, which drops empty / pre-2000 dates (so the 1970-01-01 epoch becomes NULL rather than a fake date).
  3. COALESCE to the event date. The 3 cohort-holder queries use COALESCE(p.end_date, ec.end_date) so epoch-placeholder markets fall back to the real event date from the category cache.
  4. Display unresolved past-dated held markets. /topbets marks a still-held but past-dated market as ends {date} (unresolved) (via end_date_seg, using snapshot_ts to decide past-vs-future).

Verified vs prod

marketresolved end date
kansas-governor2026-11-03
openai-ipo2026-12-31

Distinct from the earlier countdown end_date issue

This is not the correctness-pass deferred item (date-only end_date parsed as UTC midnight → countdown ≤24h off). That was a timezone/parsing issue on a present date; this is an epoch-placeholder + wrong source issue. Different bug, different fix.

Scoring/ranking untouched

Only end_date metadata + display changed. The pmv2 scoring/ranking path is not affected.