UserRatings for Albums and MediaFiles

This commit is contained in:
Deluan
2016-03-21 10:24:40 -04:00
parent 5fd9da505e
commit 0b286afa08
7 changed files with 33 additions and 26 deletions
+12 -10
View File
@@ -54,12 +54,13 @@ func (b browser) Indexes(ifModifiedSince time.Time) (domain.ArtistIndexes, time.
}
type DirectoryInfo struct {
Id string
Name string
Entries Entries
Parent string
Starred time.Time
PlayCount int32
Id string
Name string
Entries Entries
Parent string
Starred time.Time
PlayCount int32
UserRating int
}
func (c browser) Directory(id string) (*DirectoryInfo, error) {
@@ -100,10 +101,11 @@ func (c browser) buildArtistDir(a *domain.Artist, albums domain.Albums) *Directo
func (c browser) buildAlbumDir(al *domain.Album, tracks domain.MediaFiles) *DirectoryInfo {
dir := &DirectoryInfo{
Id: al.Id,
Name: al.Name,
Parent: al.ArtistId,
PlayCount: int32(al.PlayCount),
Id: al.Id,
Name: al.Name,
Parent: al.ArtistId,
PlayCount: int32(al.PlayCount),
UserRating: al.Rating,
}
if al.Starred {
dir.Starred = al.UpdatedAt
+3
View File
@@ -31,6 +31,7 @@ type Entry struct {
AlbumId string
ArtistId string
Type string
UserRating int
UserName string
MinutesAgo int
@@ -62,6 +63,7 @@ func FromAlbum(al *domain.Album) Entry {
c.Created = al.CreatedAt
c.AlbumId = al.Id
c.ArtistId = al.ArtistId
c.UserRating = al.Rating
return c
}
@@ -94,5 +96,6 @@ func FromMediaFile(mf *domain.MediaFile) Entry {
c.AlbumId = mf.AlbumId
c.ArtistId = mf.ArtistId
c.Type = "music" // TODO Hardcoded for now
c.UserRating = mf.Rating
return c
}