mirror of
https://github.com/navidrome/navidrome.git
synced 2026-11-17 15:48:39 +01:00
Add artistImageUrl available in getArtists endpoint
Also cache artist info in the DB for 1 hour
This commit is contained in:
parent
7583ddac65
commit
cfad35544b
15 changed files with 388 additions and 193 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue