Batch: explore catalog + UI, Go 1.26, Soulseek downloads, CI fixes #273

Merged
yonlu merged 21 commits from batch/258-272 into main 2026-09-27 01:45:19 +00:00
2 changed files with 23 additions and 11 deletions
Showing only changes of commit 7b42b9ce56 - Show all commits

No files matched your search

+17 -11
View File
@@ -383,9 +383,13 @@ func (si *SearchIndex) topByPopularity(
// MusicBrainz IDs, so this never touches the library tables and asks // MusicBrainz IDs, so this never touches the library tables and asks
// one query rather than one per artist. // one query rather than one per artist.
// //
// The artists are drawn most-popular-owned-album first, so a large // **The row is drawn at random, and that is the whole point of it.**
// library's pool is the part of it the user is likeliest to recognise // Ordered by popularity it was a second leaderboard: the same handful of
// rather than whichever artists sort first. // big names appeared every time the page opened, which is not what "you
// own one album by these artists" is saying. The pool is still bounded
// to `pool` artists — a 4 000-artist library does not need all of them
// ranked — but which of them, and which of their albums, is `RANDOM()`,
// so the shelf is a different sample each visit.
func (si *SearchIndex) unownedAlbumsBySinglyOwnedArtists( func (si *SearchIndex) unownedAlbumsBySinglyOwnedArtists(
ctx context.Context, ctx context.Context,
pool, limit int, pool, limit int,
@@ -396,15 +400,17 @@ func (si *SearchIndex) unownedAlbumsBySinglyOwnedArtists(
WHERE entity_type = 2 /* release_group */ WHERE entity_type = 2 /* release_group */
AND in_library = 0 AND in_library = 0
AND artist_mbid IN ( AND artist_mbid IN (
SELECT artist_mbid FROM explore_index SELECT artist_mbid FROM (
WHERE entity_type = 2 /* release_group */ SELECT artist_mbid FROM explore_index
AND in_library = 1 WHERE entity_type = 2 /* release_group */
AND artist_mbid != x'' AND in_library = 1
GROUP BY artist_mbid AND artist_mbid != x''
HAVING COUNT(*) = 1 GROUP BY artist_mbid
ORDER BY MAX(popularity) DESC HAVING COUNT(*) = 1
)
ORDER BY RANDOM()
LIMIT ?) LIMIT ?)
ORDER BY popularity DESC ORDER BY RANDOM()
LIMIT ?`, LIMIT ?`,
pool, limit, pool, limit,
)) ))
+6
View File
@@ -3,6 +3,7 @@ package explore
import ( import (
"context" "context"
"log/slog" "log/slog"
"sort"
"testing" "testing"
"yellowjacket/backend/database" "yellowjacket/backend/database"
@@ -202,6 +203,11 @@ func TestShelves_MoreFromOwnedNeedsExactlyOneOwnedAlbum(t *testing.T) {
titles = append(titles, album.Title) titles = append(titles, album.Title)
} }
// The row is a random sample, so the *set* is what is asserted and
// not the order — see `unownedAlbumsBySinglyOwnedArtists` for why
// the ordering was given up.
sort.Strings(titles)
if len(titles) != 2 || titles[0] != "Second" || titles[1] != "Third" { if len(titles) != 2 || titles[0] != "Second" || titles[1] != "Third" {
t.Fatalf("albums = %v, want [Second Third]", titles) t.Fatalf("albums = %v, want [Second Third]", titles)
} }