well i guess i can POST releases now!

Signed-off-by: ari melody <ari@arimelody.me>
This commit is contained in:
ari melody 2024-08-01 03:54:15 +01:00
parent 10f5f51e76
commit 151b2d8fd9
13 changed files with 417 additions and 203 deletions

View file

@ -7,42 +7,42 @@ import (
)
type Credit struct {
artist *Artist
role string
primary bool
Artist *Artist `json:"artist"`
Role string `json:"role"`
Primary bool `json:"primary"`
}
// GETTERS
func (credit Credit) GetArtist() Artist {
return *credit.artist
return *credit.Artist
}
func (credit Credit) GetRole() string {
return credit.role
return credit.Role
}
func (credit Credit) IsPrimary() bool {
return credit.primary
return credit.Primary
}
// SETTERS
func (credit Credit) SetArtist(artist *Artist) error {
// TODO: update DB
credit.artist = artist
credit.Artist = artist
return nil
}
func (credit Credit) SetRole(role string) error {
// TODO: update DB
credit.role = role
credit.Role = role
return nil
}
func (credit Credit) SetPrimary(primary bool) error {
// TODO: update DB
credit.primary = primary
credit.Primary = primary
return nil
}
@ -61,16 +61,16 @@ func PullReleaseCredits(db *sqlx.DB, releaseID string) ([]Credit, error) {
var credit = Credit{}
err = credit_rows.Scan(
&artistID,
&credit.role,
&credit.primary,
&credit.Role,
&credit.Primary,
)
if err != nil {
fmt.Printf("Error while pulling credit for release %s: %s\n", releaseID, err)
continue
}
credit.artist = GetArtist(artistID)
if credit.artist == nil {
credit.Artist = GetArtist(artistID)
if credit.Artist == nil {
// this should absolutely not happen ever due to foreign key
// constraints, but it doesn't hurt to be sure!
fmt.Printf("Error while pulling credit for release %s: Artist %s does not exist\n", releaseID, artistID)