Remove non-album artist_ids from the DB

This commit is contained in:
Deluan
2021-11-05 20:24:41 -04:00
parent 0d9dcebf32
commit 1c82bf5179
5 changed files with 53 additions and 1 deletions
+7
View File
@@ -177,6 +177,13 @@ func (r *mediaFileRepository) DeleteByPath(basePath string) (int64, error) {
return r.executeSQL(del)
}
func (r *mediaFileRepository) removeNonAlbumArtistIds() error {
upd := Update(r.tableName).Set("artist_id", "").Where(notExists("artist", ConcatExpr("id = artist_id")))
log.Debug(r.ctx, "Removing non-album artist_id")
_, err := r.executeSQL(upd)
return err
}
func (r *mediaFileRepository) Search(q string, offset int, size int) (model.MediaFiles, error) {
results := model.MediaFiles{}
err := r.doSearch(q, offset, size, &results, "title")