mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-16 12:10:36 +03:00
refactor: more SQL logs
This commit is contained in:
parent
cdbbb2f596
commit
0b91d8a30e
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user