Skip to content

Commit

Permalink
Fix scraping stash-box performers with null birthdates
Browse files Browse the repository at this point in the history
  • Loading branch information
InfiniteStash committed Oct 29, 2024
1 parent 89f539e commit b7fdefd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 81 deletions.
9 changes: 1 addition & 8 deletions graphql/stash-box/query.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ fragment TagFragment on Tag {
id
}

fragment FuzzyDateFragment on FuzzyDate {
date
accuracy
}

fragment MeasurementsFragment on Measurements {
band_size
cup_size
Expand All @@ -60,9 +55,7 @@ fragment PerformerFragment on Performer {
images {
...ImageFragment
}
birthdate {
...FuzzyDateFragment
}
birth_date
ethnicity
country
eye_color
Expand Down
80 changes: 10 additions & 70 deletions pkg/scraper/stashbox/graphql/generated_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 14 additions & 3 deletions pkg/scraper/stashbox/stash_box.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -1356,3 +1355,15 @@ func (c *Client) submitDraft(ctx context.Context, query string, input interface{

return err
}

func padFuzzyDate(date *string) *string {
var paddedDate string
if len(*date) == 10 {
return date
} else if len(*date) == 7 {
paddedDate = fmt.Sprintf("%s-01", *date)
} else if len(*date) == 4 {
paddedDate = fmt.Sprintf("%s-01-01", *date)
}
return &paddedDate
}

0 comments on commit b7fdefd

Please sign in to comment.