Purge empty albums/artists

This commit is contained in:
Deluan
2020-01-17 23:28:11 -05:00
parent ea9ed4a287
commit 54d13d2022
5 changed files with 24 additions and 0 deletions
+6
View File
@@ -157,6 +157,12 @@ func (r *albumRepository) PurgeInactive(activeList model.Albums) error {
})
}
func (r *albumRepository) PurgeEmpty() error {
o := Db()
_, err := o.Raw("delete from album where id not in (select distinct(album_id) from media_file)").Exec()
return err
}
func (r *albumRepository) GetStarred(options ...model.QueryOptions) (model.Albums, error) {
var starred []album
_, err := r.newQuery(Db(), options...).Filter("starred", true).All(&starred)
+6
View File
@@ -160,6 +160,12 @@ func (r *artistRepository) PurgeInactive(activeList model.Artists) error {
})
}
func (r *artistRepository) PurgeEmpty() error {
o := Db()
_, err := o.Raw("delete from artist where id not in (select distinct(artist_id) from album)").Exec()
return err
}
func (r *artistRepository) Search(q string, offset int, size int) (model.Artists, error) {
if len(q) <= 2 {
return nil, nil