Batch: explore catalog + UI, Go 1.26, Soulseek downloads, CI fixes #273
No files matched your search
@@ -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 (
|
||||||
SELECT artist_mbid FROM explore_index
|
SELECT artist_mbid FROM explore_index
|
||||||
WHERE entity_type = 2 /* release_group */
|
WHERE entity_type = 2 /* release_group */
|
||||||
AND in_library = 1
|
AND in_library = 1
|
||||||
AND artist_mbid != x''
|
AND artist_mbid != x''
|
||||||
GROUP BY artist_mbid
|
GROUP BY artist_mbid
|
||||||
HAVING COUNT(*) = 1
|
HAVING COUNT(*) = 1
|
||||||
ORDER BY MAX(popularity) DESC
|
)
|
||||||
|
ORDER BY RANDOM()
|
||||||
LIMIT ?)
|
LIMIT ?)
|
||||||
ORDER BY popularity DESC
|
ORDER BY RANDOM()
|
||||||
LIMIT ?`,
|
LIMIT ?`,
|
||||||
pool, limit,
|
pool, limit,
|
||||||
))
|
))
|
||||||
|
|||||||
@@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user