feat: Your genres leads with the genres you play most, not A to Z
release / web (push) Successful in 1m8s
release / go (push) Successful in 1m40s
release / govulncheck (push) Successful in 18s
release / integration (push) Successful in 3m43s
release / android (push) Successful in 4m21s
release / Build signed APK (push) Successful in 4m55s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 22s
release / Verify release artifacts (tag releases only) (push) Skipped

The genre mix builder already ranks genres by how much you listen to
them (taste profile, then plays and likes, then library size), but the
rank was lost when the mixes were stored and both apps sorted the shelf
by name. Each playlist now has a shelf_rank (migration 0107), which the
genre builder fills 1..n in that listening order, even where it picked a
narrower genre before a broader one. The list and detail endpoints carry
it, and the web and Android Home sort the genre shelf by it, unranked
playlists after by name. Android's playlist cache gains the column
(Room v14).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-24 18:10:08 -05:00
co-authored by Claude Opus 5.5
parent 7cc14da1a7
commit 104f9fd141
25 changed files with 220 additions and 41 deletions
+21
View File
@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"log/slog"
"sort"
"time"
"github.com/jackc/pgx/v5/pgtype"
@@ -123,6 +124,10 @@ func produceGenreMixes(
// shelf does not have yet. It takes tier-3 genres only while the shelf is
// below genreMixMinShelf. build is handed the genres kept so far, whose songs
// the new mix leaves out.
//
// The mixes it keeps are ranked for the shelf in the candidates' own order
// (tier, then score: the genres the user listens to most first), not in the
// order they were picked, which puts specific genres ahead of broad ones.
func selectGenreMixes(
cands []genreCandidate, build func(genreCandidate, []string) []rankedCandidate,
) []builtPlaylist {
@@ -136,6 +141,7 @@ func selectGenreMixes(
owned := map[pgtype.UUID]struct{}{}
kept := []string{}
var out []builtPlaylist
var picked []int // the candidate index of each mix in out
for _, i := range specificFirst(cands, sets) {
c := cands[i]
if len(out) >= genreMixCount {
@@ -160,10 +166,25 @@ func selectGenreMixes(
Variant: "genre_mix",
Tracks: tracks,
})
picked = append(picked, i)
}
rankByCandidate(out, picked)
return out
}
// rankByCandidate numbers each mix's ShelfRank from 1 by its candidate
// index: the lower the index, the more the user listens to the genre.
func rankByCandidate(out []builtPlaylist, picked []int) {
order := make([]int, len(out))
for k := range order {
order[k] = k
}
sort.Slice(order, func(a, b int) bool { return picked[order[a]] < picked[order[b]] })
for rank, k := range order {
out[k].ShelfRank = int32(rank + 1)
}
}
// specificFirst returns the candidates' indexes in rank order, except that
// within each tier the broad genres come after the specific ones.
func specificFirst(cands []genreCandidate, sets []map[pgtype.UUID]struct{}) []int {