Fix scraping stash-box performers with null birthdates (#5428)

This commit is contained in:
InfiniteStash
2024-10-31 01:55:58 +01:00
committed by GitHub
parent 89f539ee24
commit b1d5dc2a0e
3 changed files with 30 additions and 81 deletions

View File

@@ -648,9 +648,8 @@ func performerFragmentToScrapedPerformer(p graphql.PerformerFragment) *models.Sc
sp.Height = &hs
}
if p.Birthdate != nil {
b := p.Birthdate.Date
sp.Birthdate = &b
if p.BirthDate != nil {
sp.Birthdate = padFuzzyDate(p.BirthDate)
}
if p.Gender != nil {
@@ -1356,3 +1355,20 @@ func (c *Client) submitDraft(ctx context.Context, query string, input interface{
return err
}
func padFuzzyDate(date *string) *string {
if date == nil {
return nil
}
var paddedDate string
switch len(*date) {
case 10:
paddedDate = *date
case 7:
paddedDate = fmt.Sprintf("%s-01", *date)
case 4:
paddedDate = fmt.Sprintf("%s-01-01", *date)
}
return &paddedDate
}