add more detail to credits on /api/v1/artist/{id}

This commit is contained in:
ari melody 2024-10-20 20:05:30 +01:00
parent 1846203076
commit e2ec731109
Signed by: ari
GPG key ID: CF99829C92678188

View file

@ -8,6 +8,7 @@ import (
"os"
"path/filepath"
"strings"
"time"
"arimelody-web/admin"
"arimelody-web/global"
@ -38,8 +39,12 @@ func ServeArtist(artist *model.Artist) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
type (
creditJSON struct {
Role string `json:"role"`
Primary bool `json:"primary"`
ID string `json:"id"`
Title string `json:"title"`
ReleaseDate time.Time `json:"releaseDate" db:"release_date"`
Artwork string `json:"artwork"`
Role string `json:"role"`
Primary bool `json:"primary"`
}
artistJSON struct {
*model.Artist
@ -60,6 +65,10 @@ func ServeArtist(artist *model.Artist) http.Handler {
var credits = map[string]creditJSON{}
for _, credit := range dbCredits {
credits[credit.Release.ID] = creditJSON{
ID: credit.Release.ID,
Title: credit.Release.Title,
ReleaseDate: credit.Release.ReleaseDate,
Artwork: credit.Release.Artwork,
Role: credit.Role,
Primary: credit.Primary,
}