mirror of
https://github.com/navidrome/navidrome.git
synced 2025-12-23 23:18:05 -05:00
fix artist refreshstats query
Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
@@ -63,6 +63,8 @@ func trackScanAsSubprocess(ctx context.Context, progress <-chan *scanner.Progres
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runScanner(ctx context.Context) {
|
func runScanner(ctx context.Context) {
|
||||||
|
defer db.Init(ctx)()
|
||||||
|
|
||||||
sqlDB := db.Db()
|
sqlDB := db.Db()
|
||||||
defer db.Db().Close()
|
defer db.Db().Close()
|
||||||
ds := persistence.New(sqlDB)
|
ds := persistence.New(sqlDB)
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
-- +goose Up
|
||||||
|
-- Add index on artist_id for media_file_artists table to improve query performance
|
||||||
|
-- This index is crucial for the RefreshStats query in artistRepository
|
||||||
|
CREATE INDEX IF NOT EXISTS media_file_artists_artist_id ON media_file_artists(artist_id);
|
||||||
|
|
||||||
|
-- +goose Down
|
||||||
|
DROP INDEX IF EXISTS media_file_artists_artist_id;
|
||||||
@@ -399,7 +399,7 @@ func (r *artistRepository) RefreshStats(allArtists bool) (int64, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Template for the batch update with placeholder markers that we'll replace
|
// Template for the batch update with placeholder markers that we'll replace
|
||||||
// This now calculates per-library statistics and stores them in library_artist.stats
|
// This calculates per-library statistics and stores them in library_artist.stats
|
||||||
batchUpdateStatsSQL := `
|
batchUpdateStatsSQL := `
|
||||||
WITH artist_role_counters AS (
|
WITH artist_role_counters AS (
|
||||||
SELECT mfa.artist_id,
|
SELECT mfa.artist_id,
|
||||||
|
|||||||
Reference in New Issue
Block a user