Skip to content

🎧 Your Personal Streaming Service

refactor: more SQL logs

Deluan0b91d8a30eab
diff --git a/persistence/album_repository.go b/persistence/album_repository.go
index 898fa3e9b..136fdb566 100644
--- a/persistence/album_repository.go
+++ b/persistence/album_repository.go
@@ -130,20 +130,20 @@ func (r *albumRepository) Refresh(ids ...string) error {
}
}
if toInsert > 0 {
- log.Debug(r.ctx, "Inserted new albums", "num", toInsert)
+ log.Debug(r.ctx, "Inserted new albums", "totalInserted", toInsert)
}
if toUpdate > 0 {
- log.Debug(r.ctx, "Updated albums", "num", toUpdate)
+ log.Debug(r.ctx, "Updated albums", "totalUpdated", toUpdate)
}
return err
}
func (r *albumRepository) PurgeEmpty() error {
- rs, err := r.ormer.Raw("delete from album where id not in (select distinct(album_id) from media_file)").Exec()
+ del := Delete(r.tableName).Where("id not in (select distinct(album_id) from media_file)")
+ c, err := r.executeSQL(del)
if err == nil {
- c, _ := rs.RowsAffected()
if c > 0 {
- log.Debug(r.ctx, "Purged empty albums", "num", c)
+ log.Debug(r.ctx, "Purged empty albums", "totalDeleted", c)
}
}
return err
diff --git a/persistence/artist_repository.go b/persistence/artist_repository.go
index 777b0d59a..826203d25 100644
--- a/persistence/artist_repository.go
+++ b/persistence/artist_repository.go
@@ -148,10 +148,10 @@ where f.artist_id in ('%s') group by f.artist_id order by f.id`, strings.Join(id
}
}
if toInsert > 0 {
- log.Debug(r.ctx, "Inserted new artists", "num", toInsert)
+ log.Debug(r.ctx, "Inserted new artists", "totalInserted", toInsert)
}
if toUpdate > 0 {
- log.Debug(r.ctx, "Updated artists", "num", toUpdate)
+ log.Debug(r.ctx, "Updated artists", "totalUpdated", toUpdate)
}
return err
}
@@ -164,7 +164,13 @@ func (r *artistRepository) GetStarred(options ...model.QueryOptions) (model.Arti
}
func (r *artistRepository) PurgeEmpty() error {
- _, err := r.ormer.Raw("delete from artist where id not in (select distinct(artist_id) from album)").Exec()
+ del := Delete(r.tableName).Where("id not in (select distinct(artist_id) from album)")
+ c, err := r.executeSQL(del)
+ if err == nil {
+ if c > 0 {
+ log.Debug(r.ctx, "Purged empty artists", "totalDeleted", c)
+ }
+ }
return err
}