Summary
The creator detail and trending endpoints both need a price change percentage over different windows (1h, 24h, 7d). Each currently computes this differently with duplicated time window logic. A shared helper should accept a configurable window and return the percentage change for any creator.
Scope
- Add
computePriceChange(creatorId: string, windowMs: number, db: Database): Promise<number | null>
- Fetch the oldest snapshot within the window and the latest snapshot; return null if fewer than two snapshots exist
- Return the percentage change as a signed float rounded to two decimal places
- Add unit tests: positive change, negative change, null when only one snapshot, null when no snapshots
Acceptance Criteria
ETA: 12 hours
Coordinate on Telegram
Summary
The creator detail and trending endpoints both need a price change percentage over different windows (1h, 24h, 7d). Each currently computes this differently with duplicated time window logic. A shared helper should accept a configurable window and return the percentage change for any creator.
Scope
computePriceChange(creatorId: string, windowMs: number, db: Database): Promise<number | null>Acceptance Criteria
ETA: 12 hours
Coordinate on Telegram