Add artistImageUrl available in getArtists endpoint

Also cache artist info in the DB for 1 hour
This commit is contained in:
Deluan
2020-10-30 16:08:43 -04:00
parent 7583ddac65
commit cfad35544b
15 changed files with 390 additions and 195 deletions
+29 -10
View File
@@ -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