add artists list to /api/v1/music
This commit is contained in:
parent
bc1b6c5872
commit
e69cf78e57
|
@ -7,7 +7,7 @@ tmp_dir = "tmp"
|
|||
bin = "./tmp/main"
|
||||
cmd = "go build -o ./tmp/main ."
|
||||
delay = 1000
|
||||
exclude_dir = ["admin\\static", "public", "uploads", "test"]
|
||||
exclude_dir = ["admin/static", "public", "uploads", "test", "db"]
|
||||
exclude_file = []
|
||||
exclude_regex = ["_test.go"]
|
||||
exclude_unchanged = false
|
||||
|
|
|
@ -27,6 +27,7 @@ func ServeCatalog() http.Handler {
|
|||
type Release struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Artists []string `json:"artists"`
|
||||
ReleaseType model.ReleaseType `json:"type" db:"type"`
|
||||
ReleaseDate time.Time `json:"releaseDate" db:"release_date"`
|
||||
Artwork string `json:"artwork"`
|
||||
|
@ -40,9 +41,15 @@ func ServeCatalog() http.Handler {
|
|||
if !release.Visible && !authorised {
|
||||
continue
|
||||
}
|
||||
artists := []string{}
|
||||
for _, credit := range release.Credits {
|
||||
if !credit.Primary { continue }
|
||||
artists = append(artists, credit.Artist.Name)
|
||||
}
|
||||
catalog = append(catalog, Release{
|
||||
ID: release.ID,
|
||||
Title: release.Title,
|
||||
Artists: artists,
|
||||
ReleaseType: release.ReleaseType,
|
||||
ReleaseDate: release.ReleaseDate,
|
||||
Artwork: release.Artwork,
|
||||
|
|
|
@ -66,17 +66,17 @@ func GetAllReleases(db *sqlx.DB, onlyVisible bool, limit int, full bool) ([]*mod
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if full {
|
||||
for _, release := range releases {
|
||||
// get credits
|
||||
credits, err := GetReleaseCredits(db, release.ID)
|
||||
if err != nil {
|
||||
return nil, errors.New(fmt.Sprintf("Credits: %s", err))
|
||||
}
|
||||
for _, credit := range credits {
|
||||
release.Credits = append(release.Credits, credit)
|
||||
}
|
||||
for _, release := range releases {
|
||||
// get credits
|
||||
credits, err := GetReleaseCredits(db, release.ID)
|
||||
if err != nil {
|
||||
return nil, errors.New(fmt.Sprintf("Credits: %s", err))
|
||||
}
|
||||
for _, credit := range credits {
|
||||
release.Credits = append(release.Credits, credit)
|
||||
}
|
||||
|
||||
if full {
|
||||
// get tracks
|
||||
tracks, err := GetReleaseTracks(db, release.ID)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue