design: sync unliked tracks — remove from show and re-compact positions
Nick is the host; if he unlikes a track, the service should respect that and remove it from the show playlist. Positions re-compact after removal. The tracks table retains the record for historical reference. Made-with: Cursor
This commit is contained in:
@@ -68,7 +68,7 @@ Join table linking tracks to shows with position.
|
||||
|
||||
Position assignment: likes sorted by `liked_at` ascending (oldest first), positions assigned 1, 2, 3... New likes mid-week get the next position; existing positions never shift.
|
||||
|
||||
Once a track is assigned a position in a show, it stays even if Nick unlikes it. Admin endpoints exist for manual corrections.
|
||||
If Nick unlikes a track, the poller removes it from the show and re-compacts positions (e.g. if track at position 2 is removed, position 3 becomes 2). The `tracks` table retains the record for historical reference, but the `show_tracks` link is deleted.
|
||||
|
||||
## API Endpoints
|
||||
|
||||
@@ -135,7 +135,7 @@ Admin endpoints are protected by a bearer token (`NTR_ADMIN_TOKEN`). Read endpoi
|
||||
1. Compute current week's boundary window (Wednesday 22:00 ET -> next Wednesday 22:00 ET, converted to UTC accounting for DST via `zoneinfo`).
|
||||
2. Ensure a `shows` row exists for this window.
|
||||
3. Fetch likes from SoundCloud.
|
||||
4. Upsert new tracks, assign positions, update `show_tracks`.
|
||||
4. Sync the show playlist: upsert new tracks, remove unliked tracks, re-compact positions.
|
||||
5. Sleep for the configured interval.
|
||||
|
||||
### Incremental fetching
|
||||
@@ -167,7 +167,7 @@ Each SoundCloud HTTP call: 3 attempts, exponential backoff (2s, 4s, 8s). 401s tr
|
||||
| Network timeout | Same as 5xx |
|
||||
| `client_id` extraction failure | Log error, skip tick, retry next hour |
|
||||
| Poller task crash | Supervisor restarts after 30s backoff |
|
||||
| Nick unlikes a track | Track stays in show — positions are stable |
|
||||
| Nick unlikes a track | Track removed from show, positions re-compacted |
|
||||
|
||||
## Project Structure
|
||||
|
||||
|
||||
Reference in New Issue
Block a user