v1.0.2: Mood mix optimizations and media player improvements
- Fixed player seek flicker on podcasts (30s skip buttons) - Added dual-layer seek lock mechanism to prevent stale time updates - Optimized cached podcast seeking (direct seek before reload fallback) - Large skips now execute immediately for responsive feel - Mood mix performance optimizations
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
-- AddColumn: Artist.similarArtistsJson
|
||||
-- Stores full Last.fm similar artists data as JSON instead of FK-based SimilarArtist table
|
||||
ALTER TABLE "Artist" ADD COLUMN "similarArtistsJson" JSONB;
|
||||
@@ -0,0 +1,58 @@
|
||||
-- Add MoodBucket table for pre-computed mood assignments
|
||||
CREATE TABLE "MoodBucket" (
|
||||
"id" TEXT NOT NULL,
|
||||
"trackId" TEXT NOT NULL,
|
||||
"mood" TEXT NOT NULL,
|
||||
"score" DOUBLE PRECISION NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "MoodBucket_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- Add UserMoodMix table for storing user's active mood mix
|
||||
CREATE TABLE "UserMoodMix" (
|
||||
"id" TEXT NOT NULL,
|
||||
"userId" TEXT NOT NULL,
|
||||
"mood" TEXT NOT NULL,
|
||||
"trackIds" TEXT[],
|
||||
"coverUrls" TEXT[],
|
||||
"generatedAt" TIMESTAMP(3) NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "UserMoodMix_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- Unique constraint: one entry per track+mood combination
|
||||
CREATE UNIQUE INDEX "MoodBucket_trackId_mood_key" ON "MoodBucket"("trackId", "mood");
|
||||
|
||||
-- Index for fast mood lookups sorted by score
|
||||
CREATE INDEX "MoodBucket_mood_score_idx" ON "MoodBucket"("mood", "score" DESC);
|
||||
|
||||
-- Index for track lookups
|
||||
CREATE INDEX "MoodBucket_trackId_idx" ON "MoodBucket"("trackId");
|
||||
|
||||
-- Unique constraint: one mood mix per user
|
||||
CREATE UNIQUE INDEX "UserMoodMix_userId_key" ON "UserMoodMix"("userId");
|
||||
|
||||
-- Index for user lookups
|
||||
CREATE INDEX "UserMoodMix_userId_idx" ON "UserMoodMix"("userId");
|
||||
|
||||
-- Foreign key constraints
|
||||
ALTER TABLE "MoodBucket" ADD CONSTRAINT "MoodBucket_trackId_fkey" FOREIGN KEY ("trackId") REFERENCES "Track"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE "UserMoodMix" ADD CONSTRAINT "UserMoodMix_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- Add indexes to Track table for mood-related columns (for query optimization)
|
||||
CREATE INDEX IF NOT EXISTS "Track_analysisMode_idx" ON "Track"("analysisMode");
|
||||
CREATE INDEX IF NOT EXISTS "Track_moodHappy_idx" ON "Track"("moodHappy");
|
||||
CREATE INDEX IF NOT EXISTS "Track_moodSad_idx" ON "Track"("moodSad");
|
||||
CREATE INDEX IF NOT EXISTS "Track_moodRelaxed_idx" ON "Track"("moodRelaxed");
|
||||
CREATE INDEX IF NOT EXISTS "Track_moodAggressive_idx" ON "Track"("moodAggressive");
|
||||
CREATE INDEX IF NOT EXISTS "Track_moodParty_idx" ON "Track"("moodParty");
|
||||
CREATE INDEX IF NOT EXISTS "Track_moodAcoustic_idx" ON "Track"("moodAcoustic");
|
||||
CREATE INDEX IF NOT EXISTS "Track_moodElectronic_idx" ON "Track"("moodElectronic");
|
||||
CREATE INDEX IF NOT EXISTS "Track_arousal_idx" ON "Track"("arousal");
|
||||
CREATE INDEX IF NOT EXISTS "Track_acousticness_idx" ON "Track"("acousticness");
|
||||
CREATE INDEX IF NOT EXISTS "Track_instrumentalness_idx" ON "Track"("instrumentalness");
|
||||
@@ -42,6 +42,7 @@ model User {
|
||||
deviceLinkCodes DeviceLinkCode[]
|
||||
hiddenPlaylists HiddenPlaylist[]
|
||||
notifications Notification[]
|
||||
userMoodMix UserMoodMix?
|
||||
}
|
||||
|
||||
model UserSettings {
|
||||
@@ -129,17 +130,18 @@ model SystemSettings {
|
||||
}
|
||||
|
||||
model Artist {
|
||||
id String @id @default(cuid())
|
||||
mbid String @unique
|
||||
name String
|
||||
normalizedName String @default("") // Lowercase version for case-insensitive matching
|
||||
summary String? @db.Text
|
||||
heroUrl String?
|
||||
genres Json? // Array of genre strings from Last.fm/MusicBrainz
|
||||
lastSynced DateTime @default(now())
|
||||
lastEnriched DateTime?
|
||||
enrichmentStatus String @default("pending") // pending, enriching, completed, failed
|
||||
searchVector Unsupported("tsvector")?
|
||||
id String @id @default(cuid())
|
||||
mbid String @unique
|
||||
name String
|
||||
normalizedName String @default("") // Lowercase version for case-insensitive matching
|
||||
summary String? @db.Text
|
||||
heroUrl String?
|
||||
genres Json? // Array of genre strings from Last.fm/MusicBrainz
|
||||
similarArtistsJson Json? // Full Last.fm similar artists data [{name, mbid, match, image}]
|
||||
lastSynced DateTime @default(now())
|
||||
lastEnriched DateTime?
|
||||
enrichmentStatus String @default("pending") // pending, enriching, completed, failed
|
||||
searchVector Unsupported("tsvector")?
|
||||
|
||||
albums Album[]
|
||||
similarFrom SimilarArtist[] @relation("FromArtist")
|
||||
@@ -248,16 +250,28 @@ model Track {
|
||||
likedBy LikedTrack[]
|
||||
cachedBy CachedTrack[]
|
||||
transcodedFiles TranscodedFile[]
|
||||
moodBuckets MoodBucket[]
|
||||
|
||||
@@index([albumId])
|
||||
@@index([fileModified])
|
||||
@@index([title])
|
||||
@@index([searchVector], type: Gin)
|
||||
@@index([analysisStatus])
|
||||
@@index([analysisMode])
|
||||
@@index([bpm])
|
||||
@@index([energy])
|
||||
@@index([valence])
|
||||
@@index([danceability])
|
||||
@@index([moodHappy])
|
||||
@@index([moodSad])
|
||||
@@index([moodRelaxed])
|
||||
@@index([moodAggressive])
|
||||
@@index([moodParty])
|
||||
@@index([moodAcoustic])
|
||||
@@index([moodElectronic])
|
||||
@@index([arousal])
|
||||
@@index([acousticness])
|
||||
@@index([instrumentalness])
|
||||
}
|
||||
|
||||
// Transcoded file cache for audio streaming
|
||||
@@ -881,6 +895,44 @@ model DeviceLinkCode {
|
||||
@@index([userId])
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// Mood Mixer System (Pre-computed Mood Buckets)
|
||||
// ============================================
|
||||
|
||||
// Pre-computed mood assignments for fast mood mix generation
|
||||
// Tracks are assigned to mood buckets during audio analysis
|
||||
model MoodBucket {
|
||||
id String @id @default(cuid())
|
||||
trackId String
|
||||
mood String // happy, sad, chill, energetic, party, focus, melancholy, aggressive, acoustic
|
||||
score Float // Confidence score 0-1
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
track Track @relation(fields: [trackId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([trackId, mood])
|
||||
@@index([mood, score(sort: Desc)])
|
||||
@@index([trackId])
|
||||
}
|
||||
|
||||
// User's active mood mix selection
|
||||
// Stores the last generated mood mix for display on the home page
|
||||
model UserMoodMix {
|
||||
id String @id @default(cuid())
|
||||
userId String @unique
|
||||
mood String // The selected mood (happy, sad, etc.)
|
||||
trackIds String[] // Cached track IDs for the mix
|
||||
coverUrls String[] // Cached cover URLs for display
|
||||
generatedAt DateTime // When this mix was generated
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([userId])
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// Enums
|
||||
// ============================================
|
||||
|
||||
Reference in New Issue
Block a user