Skip to content

🎧 Your Personal Streaming Service

fix: check if album is starred before adding the starred date in the response. also return "starred" in search responses

Deluan33ede13eef41
diff --git a/engine/browser.go b/engine/browser.go
index a929fb1b6..36234422b 100644
--- a/engine/browser.go
+++ b/engine/browser.go
@@ -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
}
diff --git a/engine/common.go b/engine/common.go
index 24e09dcb8..91ac4207f 100644
--- a/engine/common.go
+++ b/engine/common.go
@@ -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
}
@@ -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
@@ -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
}
diff --git a/persistence/album_repository.go b/persistence/album_repository.go
index 2da2d4700..6b1e7a076 100644
--- a/persistence/album_repository.go
+++ b/persistence/album_repository.go
@@ -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) {
diff --git a/persistence/artist_repository.go b/persistence/artist_repository.go
index 05b55a634..4f4fbaaa9 100644
--- a/persistence/artist_repository.go
+++ b/persistence/artist_repository.go
@@ -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) {
diff --git a/persistence/sql_search.go b/persistence/sql_search.go
index 816ced695..9f5bf9612 100644
--- a/persistence/sql_search.go
+++ b/persistence/sql_search.go
@@ -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...)