Goal
Populate the price_history table with initial data for all 118 hypotheses. Currently, price_history is empty (0 rows) while market_transactions has 8 rows and hypotheses has 118 rows. Each hypothesis needs at least one initial entry showing its listing price. This will enable the /api/hypothesis/{id}/history endpoint to return meaningful data and allow sparkline visualizations to work on hypothesis detail pages.
Acceptance Criteria
☑ Create initial price_history entries for all 118 hypotheses using their current composite_score
☑ Each entry should have event_type = 'initial_listing'
☑ Use the hypothesis created_at timestamp for the initial entry timestamp
☑ Create or verify /api/hypothesis/{id}/history endpoint returns JSON with price timeline
☑ Verify endpoint returns data for at least one hypothesis
☑ Confirm price_history table has 118+ rows after backfill
Approach
Read current state of price_history and hypotheses tables
Write Python script to backfill initial entries:
- Query all hypotheses (id, composite_score, created_at)
- For each hypothesis, insert into price_history: (hypothesis_id, price=composite_score, event_type='initial_listing', created_at=hypothesis.created_at)
Verify or create /api/hypothesis/{id}/history API endpoint in api.py
Test endpoint with curl to verify it returns data
Verify sparklines render on hypothesis detail pagesWork Log
2026-04-01 — Slot 0
- Started task: Backfill price_history table with initial data for all hypotheses
- Investigated database state:
- price_history: 0 rows (before backfill)
- market_transactions: 8 rows
- hypotheses: 118 rows
- Checked API endpoint: /api/hypothesis/{id}/history returned 404 (endpoint didn't exist)
- Created backfill script
backfill_price_history.py:
- Reads all hypotheses with their composite_score and created_at
- Inserts initial_listing entry for each hypothesis
- Idempotent - skips hypotheses that already have entries
- Ran backfill script: Successfully inserted 118 initial entries
- Added
/api/hypothesis/{hypothesis_id}/history endpoint to api.py
- Restarted scidex-api service
- Tested endpoint: Returns JSON with price timeline
- Example: h-e12109e3 returns 1 entry with price=0.608, event_type=initial_listing
- Example: h-d2722680 returns 1 entry with price=0.573, event_type=initial_listing
- Verified system status: All services running, all key pages return 200
- Result: Done — price_history table now has 118 rows, API endpoint functional
2026-04-26 — Slot 42 (task reopened)
- Task was previously completed but had no task_runs row; reopened for verification
- Current state: price_history has 78,689 rows, market_transactions 53,487, hypotheses 1,374
- Found 0
initial_listing events and 208 hypotheses with no price_history at all (newly added since original backfill)
- Inserted 208
initial_listing entries for all hypotheses missing price_history, using composite_score and created_at
- Verified
/api/hypothesis/{id}/price-history endpoint returns data (confirmed h-aging-h3-apoe-trem2 returns 1 entry with event_type=initial_listing)
- All 1,374 hypotheses now have at least one price_history entry; 208 have initial_listing specifically