feat(server/m7-365): GET /api/me/history handler + integration test

Implements the listening-history endpoint for M7 #365: returns a user's
play events newest-first, excluding skipped events and quarantined tracks,
with offset/limit pagination and a has_more heuristic.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-04 05:52:17 -04:00
parent 45a17e4e95
commit fc608fb36e
4 changed files with 257 additions and 1 deletions
+19 -1
View File
@@ -1,6 +1,10 @@
package api
import "github.com/jackc/pgx/v5/pgtype"
import (
"time"
"github.com/jackc/pgx/v5/pgtype"
)
// LoginRequest is the POST /api/auth/login body. Kept boring on purpose —
// web and Flutter both send the same payload.
@@ -112,3 +116,17 @@ type HomePayload struct {
MostPlayedTracks []TrackRef `json:"most_played_tracks"`
LastPlayedArtists []ArtistRef `json:"last_played_artists"`
}
// HistoryEvent is one play in a user's listening history. Used by
// /api/me/history; one event per row from play_events.
type HistoryEvent struct {
ID string `json:"id"` // play_events.id
PlayedAt time.Time `json:"played_at"` // play_events.started_at
Track TrackRef `json:"track"`
}
// HistoryResponse is the body of GET /api/me/history.
type HistoryResponse struct {
Events []HistoryEvent `json:"events"`
HasMore bool `json:"has_more"`
}