Skip to content

🎧 Your Personal Streaming Service

Fix aggregated values (count, size, duration) in roll-up queries

Deluan21cd50d81c95
diff --git a/persistence/album_repository.go b/persistence/album_repository.go
index 8f5b348dd..97851b478 100644
--- a/persistence/album_repository.go
+++ b/persistence/album_repository.go
@@ -196,10 +196,9 @@ func (r *albumRepository) refresh(ids ...string) error {
group_concat(f.artist_id, ' ') as song_artist_ids,
group_concat(f.album_artist_id, ' ') as album_artist_ids,
group_concat(f.year, ' ') as years,
- group_concat(mg.genre_id, ' ') as genre_ids`).
+ (select group_concat(genre_id, ' ') from media_file_genres where media_file_id = f.id) as genre_ids`).
From("media_file f").
LeftJoin("album a on f.album_id = a.id").
- LeftJoin("media_file_genres mg on mg.media_file_id = f.id").
Where(Eq{"f.album_id": ids}).GroupBy("f.album_id")
err := r.queryAll(sel, &albums)
if err != nil {
diff --git a/persistence/artist_repository.go b/persistence/artist_repository.go
index 3482306ea..f57f4b184 100644
--- a/persistence/artist_repository.go
+++ b/persistence/artist_repository.go
@@ -197,10 +197,9 @@ func (r *artistRepository) refresh(ids ...string) error {
"group_concat(f.mbz_album_artist_id , ' ') as mbz_artist_id",
"f.sort_album_artist_name as sort_artist_name", "f.order_album_artist_name as order_artist_name",
"sum(f.song_count) as song_count", "sum(f.size) as size",
- "group_concat(ag.genre_id, ' ') as genre_ids").
+ "(select group_concat(genre_id, ' ') from album_genres where album_id = f.id) as genre_ids").
From("album f").
LeftJoin("artist a on f.album_artist_id = a.id").
- LeftJoin("album_genres ag on ag.album_id = f.id").
Where(Eq{"f.album_artist_id": ids}).
GroupBy("f.album_artist_id").OrderBy("f.id")
err := r.queryAll(sel, &artists)