refactor: annotations

This commit is contained in:
Deluan
2020-01-31 21:09:23 -05:00
committed by Deluan Quintão
parent de1fea64bc
commit 88e01d05f6
16 changed files with 184 additions and 197 deletions
+5 -5
View File
@@ -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
View File
@@ -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