fix(scanner): optimize refresh (#4059)

* fix(artist): update RefreshStats to only process artists with recently updated media files

Signed-off-by: Deluan <deluan@navidrome.org>

* fix: paginate Artist's RefreshStats, also replace rawSQL with Expr

Signed-off-by: Deluan <deluan@navidrome.org>

---------

Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
Deluan Quintão
2025-05-14 20:47:03 -04:00
committed by GitHub
parent ec9f9aa243
commit db92cf9e47
6 changed files with 118 additions and 78 deletions
+1 -1
View File
@@ -315,7 +315,7 @@ func (r *albumRepository) GetTouchedAlbums(libID int) (model.AlbumCursor, error)
// RefreshPlayCounts updates the play count and last play date annotations for all albums, based
// on the media files associated with them.
func (r *albumRepository) RefreshPlayCounts() (int64, error) {
query := rawSQL(`
query := Expr(`
with play_counts as (
select user_id, album_id, sum(play_count) as total_play_count, max(play_date) as last_play_date
from media_file