fix(scanner): filter folders by num_audio_files to ensure accurate statistics
Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
@@ -30,7 +30,7 @@ update library set
|
|||||||
join artist a on la.artist_id = a.id
|
join artist a on la.artist_id = a.id
|
||||||
where la.library_id = library.id and a.missing = 0
|
where la.library_id = library.id and a.missing = 0
|
||||||
),
|
),
|
||||||
total_folders = (select count(*) from folder where library_id = library.id and missing = 0),
|
total_folders = (select count(*) from folder where library_id = library.id and missing = 0 and num_audio_files > 0),
|
||||||
total_files = (
|
total_files = (
|
||||||
select ifnull(sum(num_audio_files + num_playlists + json_array_length(image_files)),0)
|
select ifnull(sum(num_audio_files + num_playlists + json_array_length(image_files)),0)
|
||||||
from folder where library_id = library.id and missing = 0
|
from folder where library_id = library.id and missing = 0
|
||||||
|
|||||||
@@ -164,10 +164,15 @@ func (r *libraryRepository) RefreshStats(id int) error {
|
|||||||
Where(Eq{"la.library_id": id, "a.missing": false}), &artistsRes)
|
Where(Eq{"la.library_id": id, "a.missing": false}), &artistsRes)
|
||||||
},
|
},
|
||||||
func() error {
|
func() error {
|
||||||
return r.queryOne(Select("count(*) as count").From("folder").Where(Eq{"library_id": id, "missing": false}), &foldersRes)
|
return r.queryOne(Select("count(*) as count").From("folder").
|
||||||
|
Where(And{
|
||||||
|
Eq{"library_id": id, "missing": false},
|
||||||
|
Gt{"num_audio_files": 0},
|
||||||
|
}), &foldersRes)
|
||||||
},
|
},
|
||||||
func() error {
|
func() error {
|
||||||
return r.queryOne(Select("ifnull(sum(num_audio_files + num_playlists + json_array_length(image_files)),0) as count").From("folder").Where(Eq{"library_id": id, "missing": false}), &filesRes)
|
return r.queryOne(Select("ifnull(sum(num_audio_files + num_playlists + json_array_length(image_files)),0) as count").
|
||||||
|
From("folder").Where(Eq{"library_id": id, "missing": false}), &filesRes)
|
||||||
},
|
},
|
||||||
func() error {
|
func() error {
|
||||||
return r.queryOne(Select("count(*) as count").From("media_file").Where(Eq{"library_id": id, "missing": true}), &missingRes)
|
return r.queryOne(Select("count(*) as count").From("media_file").Where(Eq{"library_id": id, "missing": true}), &missingRes)
|
||||||
|
|||||||
Reference in New Issue
Block a user