Skip to content

Commit

Permalink
fix: check if album is starred before adding the starred date in the …
Browse files Browse the repository at this point in the history
…response. also return "starred" in search responses
  • Loading branch information
deluan committed Feb 25, 2020
1 parent e032bfc commit 33ede13
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
5 changes: 4 additions & 1 deletion engine/browser.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,13 @@ func (b *browser) buildAlbumDir(al *model.Album, tracks model.MediaFiles) *Direc
Genre: al.Genre,
CoverArt: al.CoverArtId,
PlayCount: int32(al.PlayCount),
Starred: al.StarredAt,
UserRating: al.Rating,
}

if al.Starred {
dir.Starred = al.StarredAt
}

dir.Entries = FromMediaFiles(tracks)
return dir
}
Expand Down
12 changes: 9 additions & 3 deletions engine/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ func FromArtist(ar *model.Artist) Entry {
e.Title = ar.Name
e.AlbumCount = ar.AlbumCount
e.IsDir = true
e.Starred = ar.StarredAt
if ar.Starred {
e.Starred = ar.StarredAt
}
return e
}

Expand All @@ -71,7 +73,9 @@ func FromAlbum(al *model.Album) Entry {
e.ArtistId = al.ArtistID
e.Duration = int(al.Duration)
e.SongCount = al.SongCount
e.Starred = al.StarredAt
if al.Starred {
e.Starred = al.StarredAt
}
e.PlayCount = int32(al.PlayCount)
e.UserRating = al.Rating
return e
Expand Down Expand Up @@ -107,7 +111,9 @@ func FromMediaFile(mf *model.MediaFile) Entry {
e.ArtistId = mf.ArtistID
e.Type = "music"
e.PlayCount = int32(mf.PlayCount)
e.Starred = mf.StarredAt
if mf.Starred {
e.Starred = mf.StarredAt
}
e.UserRating = mf.Rating
return e
}
Expand Down
2 changes: 1 addition & 1 deletion persistence/album_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (r *albumRepository) Put(a *model.Album) error {
}

func (r *albumRepository) selectAlbum(options ...model.QueryOptions) SelectBuilder {
return r.newSelectWithAnnotation("id", options...).Columns("*")
return r.newSelectWithAnnotation("album.id", options...).Columns("*")
}

func (r *albumRepository) Get(id string) (*model.Album, error) {
Expand Down
2 changes: 1 addition & 1 deletion persistence/artist_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func NewArtistRepository(ctx context.Context, o orm.Ormer) model.ArtistRepositor
}

func (r *artistRepository) selectArtist(options ...model.QueryOptions) SelectBuilder {
return r.newSelectWithAnnotation("id", options...).Columns("*")
return r.newSelectWithAnnotation("artist.id", options...).Columns("*")
}

func (r *artistRepository) CountAll(options ...model.QueryOptions) (int64, error) {
Expand Down
2 changes: 1 addition & 1 deletion persistence/sql_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (r sqlRepository) doSearch(q string, offset, size int, results interface{},
if len(q) < 2 {
return nil
}
sq := Select("*").From(r.tableName)
sq := r.newSelectWithAnnotation(r.tableName + ".id").Columns("*")
sq = sq.Limit(uint64(size)).Offset(uint64(offset))
if len(orderBys) > 0 {
sq = sq.OrderBy(orderBys...)
Expand Down

0 comments on commit 33ede13

Please sign in to comment.