mirror of
https://github.com/navidrome/navidrome.git
synced 2026-11-14 22:28:41 +01:00
refactor: annotations
This commit is contained in:
parent
de1fea64bc
commit
88e01d05f6
16 changed files with 184 additions and 197 deletions
|
|
@ -26,9 +26,9 @@ func (r ratings) SetRating(ctx context.Context, id string, rating int) error {
|
|||
return err
|
||||
}
|
||||
if exist {
|
||||
return r.ds.Annotation(ctx).SetRating(rating, model.AlbumItemType, id)
|
||||
return r.ds.Album(ctx).SetRating(rating, id)
|
||||
}
|
||||
return r.ds.Annotation(ctx).SetRating(rating, model.MediaItemType, id)
|
||||
return r.ds.MediaFile(ctx).SetRating(rating, id)
|
||||
}
|
||||
|
||||
func (r ratings) SetStar(ctx context.Context, star bool, ids ...string) error {
|
||||
|
|
@ -44,7 +44,7 @@ func (r ratings) SetStar(ctx context.Context, star bool, ids ...string) error {
|
|||
return err
|
||||
}
|
||||
if exist {
|
||||
err = tx.Annotation(ctx).SetStar(star, model.AlbumItemType, ids...)
|
||||
err = tx.Album(ctx).SetStar(star, ids...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -55,13 +55,13 @@ func (r ratings) SetStar(ctx context.Context, star bool, ids ...string) error {
|
|||
return err
|
||||
}
|
||||
if exist {
|
||||
err = tx.Annotation(ctx).SetStar(star, model.ArtistItemType, ids...)
|
||||
err = tx.Artist(ctx).SetStar(star, ids...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
continue
|
||||
}
|
||||
err = tx.Annotation(ctx).SetStar(star, model.MediaItemType, ids...)
|
||||
err = tx.MediaFile(ctx).SetStar(star, ids...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,11 +31,15 @@ func (s *scrobbler) Register(ctx context.Context, playerId int, trackId string,
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = s.ds.Annotation(ctx).IncPlayCount(model.MediaItemType, trackId, playTime)
|
||||
err = s.ds.MediaFile(ctx).IncPlayCount(trackId, playTime)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = s.ds.Annotation(ctx).IncPlayCount(model.AlbumItemType, mf.AlbumID, playTime)
|
||||
err = s.ds.Album(ctx).IncPlayCount(mf.AlbumID, playTime)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = s.ds.Artist(ctx).IncPlayCount(mf.ArtistID, playTime)
|
||||
return err
|
||||
})
|
||||
return mf, err
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue