Add artistImageUrl available in getArtists endpoint
Also cache artist info in the DB for 1 hour
This commit is contained in:
+29
-10
@@ -1,17 +1,36 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
type Artist struct {
|
||||
Annotations
|
||||
|
||||
ID string `json:"id" orm:"column(id)"`
|
||||
Name string `json:"name"`
|
||||
AlbumCount int `json:"albumCount"`
|
||||
SongCount int `json:"songCount"`
|
||||
FullText string `json:"fullText"`
|
||||
SortArtistName string `json:"sortArtistName"`
|
||||
OrderArtistName string `json:"orderArtistName"`
|
||||
Size int64 `json:"size"`
|
||||
MbzArtistID string `json:"mbzArtistId" orm:"column(mbz_artist_id)"`
|
||||
ID string `json:"id" orm:"column(id)"`
|
||||
Name string `json:"name"`
|
||||
AlbumCount int `json:"albumCount"`
|
||||
SongCount int `json:"songCount"`
|
||||
FullText string `json:"fullText"`
|
||||
SortArtistName string `json:"sortArtistName"`
|
||||
OrderArtistName string `json:"orderArtistName"`
|
||||
Size int64 `json:"size"`
|
||||
MbzArtistID string `json:"mbzArtistId" orm:"column(mbz_artist_id)"`
|
||||
Biography string `json:"biography"`
|
||||
SmallImageUrl string `json:"smallImageUrl"`
|
||||
MediumImageUrl string `json:"mediumImageUrl"`
|
||||
LargeImageUrl string `json:"largeImageUrl"`
|
||||
ExternalUrl string `json:"externalUrl" orm:"column(external_url)"`
|
||||
SimilarArtists Artists `json:"-" orm:"-"`
|
||||
ExternalInfoUpdatedAt time.Time `json:"externalInfoUpdatedAt"`
|
||||
}
|
||||
|
||||
func (a Artist) ArtistImageUrl() string {
|
||||
if a.MediumImageUrl != "" {
|
||||
return a.MediumImageUrl
|
||||
}
|
||||
if a.LargeImageUrl != "" {
|
||||
return a.LargeImageUrl
|
||||
}
|
||||
return a.SmallImageUrl
|
||||
}
|
||||
|
||||
type Artists []Artist
|
||||
@@ -27,7 +46,7 @@ type ArtistRepository interface {
|
||||
Exists(id string) (bool, error)
|
||||
Put(m *Artist) error
|
||||
Get(id string) (*Artist, error)
|
||||
FindByName(name string) (*Artist, error)
|
||||
GetAll(options ...QueryOptions) (Artists, error)
|
||||
GetStarred(options ...QueryOptions) (Artists, error)
|
||||
Search(q string, offset int, size int) (Artists, error)
|
||||
Refresh(ids ...string) error
|
||||
|
||||
Reference in New Issue
Block a user