Implement annotations per user

This commit is contained in:
Deluan 2020-01-21 23:01:43 -05:00
parent e03304650d
commit d7116eebd4
26 changed files with 572 additions and 262 deletions

View file

@ -12,14 +12,9 @@ type Album struct {
AlbumArtist string
Year int
Compilation bool
Starred bool
PlayCount int
PlayDate time.Time
SongCount int
Duration int
Rating int
Genre string
StarredAt time.Time
CreatedAt time.Time
UpdatedAt time.Time
}
@ -34,10 +29,8 @@ type AlbumRepository interface {
FindByArtist(artistId string) (Albums, error)
GetAll(...QueryOptions) (Albums, error)
GetRandom(...QueryOptions) (Albums, error)
GetStarred(...QueryOptions) (Albums, error)
GetStarred(userId string, options ...QueryOptions) (Albums, error)
Search(q string, offset int, size int) (Albums, error)
Refresh(ids ...string) error
PurgeEmpty() error
SetStar(star bool, ids ...string) error
MarkAsPlayed(id string, playDate time.Time) error
}

32
model/annotation.go Normal file
View file

@ -0,0 +1,32 @@
package model
import "time"
const (
ArtistItemType = "artist"
AlbumItemType = "album"
MediaItemType = "mediaFile"
)
type Annotation struct {
AnnotationID string
UserID string
ItemID string
ItemType string
PlayCount int
PlayDate time.Time
Rating int
Starred bool
StarredAt time.Time
}
type AnnotationMap map[string]Annotation
type AnnotationRepository interface {
Get(userID, itemType string, itemID string) (*Annotation, error)
GetMap(userID, itemType string, itemID []string) (AnnotationMap, error)
Delete(userID, itemType string, itemID ...string) error
IncPlayCount(userID, itemType string, itemID string, ts time.Time) error
SetStar(starred bool, userID, itemType string, ids ...string) error
SetRating(rating int, userID, itemType string, itemID string) error
}

View file

@ -1,13 +1,9 @@
package model
import "time"
type Artist struct {
ID string
Name string
AlbumCount int
Starred bool
StarredAt time.Time
}
type Artists []Artist
@ -22,7 +18,7 @@ type ArtistRepository interface {
Exists(id string) (bool, error)
Put(m *Artist) error
Get(id string) (*Artist, error)
GetStarred(...QueryOptions) (Artists, error)
GetStarred(userId string, options ...QueryOptions) (Artists, error)
SetStar(star bool, ids ...string) error
Search(q string, offset int, size int) (Artists, error)
Refresh(ids ...string) error

View file

@ -30,6 +30,7 @@ type DataStore interface {
Playlist() PlaylistRepository
Property() PropertyRepository
User() UserRepository
Annotation() AnnotationRepository
Resource(model interface{}) ResourceRepository

View file

@ -24,11 +24,6 @@ type MediaFile struct {
BitRate int
Genre string
Compilation bool
PlayCount int
PlayDate time.Time
Rating int
Starred bool
StarredAt time.Time
CreatedAt time.Time
UpdatedAt time.Time
}
@ -46,12 +41,9 @@ type MediaFileRepository interface {
Get(id string) (*MediaFile, error)
FindByAlbum(albumId string) (MediaFiles, error)
FindByPath(path string) (MediaFiles, error)
GetStarred(options ...QueryOptions) (MediaFiles, error)
GetStarred(userId string, options ...QueryOptions) (MediaFiles, error)
GetRandom(options ...QueryOptions) (MediaFiles, error)
Search(q string, offset int, size int) (MediaFiles, error)
Delete(id string) error
DeleteByPath(path string) error
SetStar(star bool, ids ...string) error
SetRating(rating int, ids ...string) error
MarkAsPlayed(id string, playTime time.Time) error
}