a98a106f6f
Adds 'discover' as an accepted system_variant on the playlists table — alongside 'for_you' and 'songs_like_artist' — and three sqlc bucket queries that back the new playlist's daily candidate selection. The three buckets surface tracks the user hasn't played and hasn't liked: - Dormant artists: artists this user has played < 10 times total. Surfaces the long tail of their library. - Cross-user likes: tracks any OTHER user has liked but this one hasn't engaged with. Empty on single-user servers; the Go-side allocator redistributes the deficit across the other two buckets. - Random unheard: pure random sample as the safety net and the cold-start fallback. All three share exclusion filters: not-played by this user, not liked by this user, not in lidarr_quarantine for this user. All order by md5(track_id || dateStr) for daily determinism — same pattern as the existing tieBreakHash logic in system.go. LIMIT values are generous (80/60/200) so the per-album (<=2) / per-artist (<=3) caps and slot redistribution in T2 have headroom. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
28 lines
1.2 KiB
SQL
28 lines
1.2 KiB
SQL
-- Adds 'discover' as an accepted system_variant alongside 'for_you'
|
|
-- and 'songs_like_artist'. Discover has no seed_artist_id (like
|
|
-- for_you), so the variant->seed coherence check is extended to
|
|
-- accept (system_variant = 'discover' AND seed_artist_id IS NULL).
|
|
--
|
|
-- Drops + re-adds both CHECK constraints; PostgreSQL doesn't have
|
|
-- ALTER CONSTRAINT for CHECK so this is the standard pattern.
|
|
|
|
ALTER TABLE playlists DROP CONSTRAINT IF EXISTS playlists_kind_variant_consistent;
|
|
ALTER TABLE playlists
|
|
ADD CONSTRAINT playlists_kind_variant_consistent CHECK (
|
|
(kind = 'user' AND system_variant IS NULL)
|
|
OR
|
|
(kind = 'system' AND system_variant IN ('for_you', 'songs_like_artist', 'discover'))
|
|
);
|
|
|
|
ALTER TABLE playlists DROP CONSTRAINT IF EXISTS playlists_seed_consistent;
|
|
ALTER TABLE playlists
|
|
ADD CONSTRAINT playlists_seed_consistent CHECK (
|
|
(system_variant IS NULL AND seed_artist_id IS NULL)
|
|
OR
|
|
(system_variant = 'for_you' AND seed_artist_id IS NULL)
|
|
OR
|
|
(system_variant = 'discover' AND seed_artist_id IS NULL)
|
|
OR
|
|
(system_variant = 'songs_like_artist' AND seed_artist_id IS NOT NULL)
|
|
);
|