Performer disambiguation and aliases (#3113)

* Refactor performer relationships
* Remove checksum from performer
* Add disambiguation, overhaul aliases
* Add disambiguation filter criterion
* Improve name matching during import
* Add disambiguation filtering in UI
* Include aliases in performer select
This commit is contained in:
WithoutPants
2022-12-01 13:54:08 +11:00
committed by GitHub
parent d2395e579c
commit 4daf0a14a2
72 changed files with 2283 additions and 993 deletions

View File

@@ -43,6 +43,7 @@ type PerformerReader interface {
match.PerformerFinder
Find(ctx context.Context, id int) (*models.Performer, error)
FindBySceneID(ctx context.Context, sceneID int) ([]*models.Performer, error)
models.AliasLoader
models.StashIDLoader
GetImage(ctx context.Context, performerID int) ([]byte, error)
}
@@ -606,15 +607,16 @@ func performerFragmentToScrapedScenePerformer(p graphql.PerformerFragment) *mode
images = append(images, image.URL)
}
sp := &models.ScrapedPerformer{
Name: &p.Name,
Country: p.Country,
Measurements: formatMeasurements(p.Measurements),
CareerLength: formatCareerLength(p.CareerStartYear, p.CareerEndYear),
Tattoos: formatBodyModifications(p.Tattoos),
Piercings: formatBodyModifications(p.Piercings),
Twitter: findURL(p.Urls, "TWITTER"),
RemoteSiteID: &id,
Images: images,
Name: &p.Name,
Disambiguation: p.Disambiguation,
Country: p.Country,
Measurements: formatMeasurements(p.Measurements),
CareerLength: formatCareerLength(p.CareerStartYear, p.CareerEndYear),
Tattoos: formatBodyModifications(p.Tattoos),
Piercings: formatBodyModifications(p.Piercings),
Twitter: findURL(p.Urls, "TWITTER"),
RemoteSiteID: &id,
Images: images,
// TODO - tags not currently supported
// graphql schema change to accommodate this. Leave off for now.
}
@@ -964,6 +966,15 @@ func (c Client) SubmitPerformerDraft(ctx context.Context, performer *models.Perf
draft := graphql.PerformerDraftInput{}
var image io.Reader
pqb := c.repository.Performer
if err := performer.LoadAliases(ctx, pqb); err != nil {
return nil, err
}
if err := performer.LoadStashIDs(ctx, pqb); err != nil {
return nil, err
}
img, _ := pqb.GetImage(ctx, performer.ID)
if img != nil {
image = bytes.NewReader(img)
@@ -972,6 +983,10 @@ func (c Client) SubmitPerformerDraft(ctx context.Context, performer *models.Perf
if performer.Name != "" {
draft.Name = performer.Name
}
// stash-box does not support Disambiguation currently
// if performer.Disambiguation != "" {
// draft.Disambiguation = performer.Disambiguation
// }
if performer.Birthdate != nil {
d := performer.Birthdate.String()
draft.Birthdate = &d
@@ -1008,8 +1023,9 @@ func (c Client) SubmitPerformerDraft(ctx context.Context, performer *models.Perf
if performer.Tattoos != "" {
draft.Tattoos = &performer.Tattoos
}
if performer.Aliases != "" {
draft.Aliases = &performer.Aliases
if len(performer.Aliases.List()) > 0 {
aliases := strings.Join(performer.Aliases.List(), ",")
draft.Aliases = &aliases
}
var urls []string