refactor: annotations
This commit is contained in:
+5
-5
@@ -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
|
||||
}
|
||||
|
||||
+6
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user