mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
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:
@@ -4,7 +4,6 @@ import (
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
"github.com/stashapp/stash/pkg/hash/md5"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"github.com/stashapp/stash/pkg/models/json"
|
||||
"github.com/stashapp/stash/pkg/models/jsonschema"
|
||||
@@ -22,30 +21,31 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
performerName = "testPerformer"
|
||||
url = "url"
|
||||
aliases = "aliases"
|
||||
careerLength = "careerLength"
|
||||
country = "country"
|
||||
ethnicity = "ethnicity"
|
||||
eyeColor = "eyeColor"
|
||||
fakeTits = "fakeTits"
|
||||
gender = "gender"
|
||||
instagram = "instagram"
|
||||
measurements = "measurements"
|
||||
piercings = "piercings"
|
||||
tattoos = "tattoos"
|
||||
twitter = "twitter"
|
||||
details = "details"
|
||||
hairColor = "hairColor"
|
||||
performerName = "testPerformer"
|
||||
disambiguation = "disambiguation"
|
||||
url = "url"
|
||||
careerLength = "careerLength"
|
||||
country = "country"
|
||||
ethnicity = "ethnicity"
|
||||
eyeColor = "eyeColor"
|
||||
fakeTits = "fakeTits"
|
||||
gender = "gender"
|
||||
instagram = "instagram"
|
||||
measurements = "measurements"
|
||||
piercings = "piercings"
|
||||
tattoos = "tattoos"
|
||||
twitter = "twitter"
|
||||
details = "details"
|
||||
hairColor = "hairColor"
|
||||
|
||||
autoTagIgnored = true
|
||||
)
|
||||
|
||||
var (
|
||||
rating = 5
|
||||
height = 123
|
||||
weight = 60
|
||||
aliases = []string{"alias1", "alias2"}
|
||||
rating = 5
|
||||
height = 123
|
||||
weight = 60
|
||||
)
|
||||
|
||||
var imageBytes = []byte("imageBytes")
|
||||
@@ -70,33 +70,35 @@ var (
|
||||
|
||||
func createFullPerformer(id int, name string) *models.Performer {
|
||||
return &models.Performer{
|
||||
ID: id,
|
||||
Name: name,
|
||||
Checksum: md5.FromString(name),
|
||||
URL: url,
|
||||
Aliases: aliases,
|
||||
Birthdate: &birthDate,
|
||||
CareerLength: careerLength,
|
||||
Country: country,
|
||||
Ethnicity: ethnicity,
|
||||
EyeColor: eyeColor,
|
||||
FakeTits: fakeTits,
|
||||
Favorite: true,
|
||||
Gender: gender,
|
||||
Height: &height,
|
||||
Instagram: instagram,
|
||||
Measurements: measurements,
|
||||
Piercings: piercings,
|
||||
Tattoos: tattoos,
|
||||
Twitter: twitter,
|
||||
CreatedAt: createTime,
|
||||
UpdatedAt: updateTime,
|
||||
Rating: &rating,
|
||||
Details: details,
|
||||
DeathDate: &deathDate,
|
||||
HairColor: hairColor,
|
||||
Weight: &weight,
|
||||
IgnoreAutoTag: autoTagIgnored,
|
||||
ID: id,
|
||||
Name: name,
|
||||
Disambiguation: disambiguation,
|
||||
URL: url,
|
||||
Aliases: models.NewRelatedStrings(aliases),
|
||||
Birthdate: &birthDate,
|
||||
CareerLength: careerLength,
|
||||
Country: country,
|
||||
Ethnicity: ethnicity,
|
||||
EyeColor: eyeColor,
|
||||
FakeTits: fakeTits,
|
||||
Favorite: true,
|
||||
Gender: gender,
|
||||
Height: &height,
|
||||
Instagram: instagram,
|
||||
Measurements: measurements,
|
||||
Piercings: piercings,
|
||||
Tattoos: tattoos,
|
||||
Twitter: twitter,
|
||||
CreatedAt: createTime,
|
||||
UpdatedAt: updateTime,
|
||||
Rating: &rating,
|
||||
Details: details,
|
||||
DeathDate: &deathDate,
|
||||
HairColor: hairColor,
|
||||
Weight: &weight,
|
||||
IgnoreAutoTag: autoTagIgnored,
|
||||
TagIDs: models.NewRelatedIDs([]int{}),
|
||||
StashIDs: models.NewRelatedStashIDs(stashIDs),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,49 +107,53 @@ func createEmptyPerformer(id int) models.Performer {
|
||||
ID: id,
|
||||
CreatedAt: createTime,
|
||||
UpdatedAt: updateTime,
|
||||
Aliases: models.NewRelatedStrings([]string{}),
|
||||
TagIDs: models.NewRelatedIDs([]int{}),
|
||||
StashIDs: models.NewRelatedStashIDs([]models.StashID{}),
|
||||
}
|
||||
}
|
||||
|
||||
func createFullJSONPerformer(name string, image string) *jsonschema.Performer {
|
||||
return &jsonschema.Performer{
|
||||
Name: name,
|
||||
URL: url,
|
||||
Aliases: aliases,
|
||||
Birthdate: birthDate.String(),
|
||||
CareerLength: careerLength,
|
||||
Country: country,
|
||||
Ethnicity: ethnicity,
|
||||
EyeColor: eyeColor,
|
||||
FakeTits: fakeTits,
|
||||
Favorite: true,
|
||||
Gender: gender,
|
||||
Height: strconv.Itoa(height),
|
||||
Instagram: instagram,
|
||||
Measurements: measurements,
|
||||
Piercings: piercings,
|
||||
Tattoos: tattoos,
|
||||
Twitter: twitter,
|
||||
Name: name,
|
||||
Disambiguation: disambiguation,
|
||||
URL: url,
|
||||
Aliases: aliases,
|
||||
Birthdate: birthDate.String(),
|
||||
CareerLength: careerLength,
|
||||
Country: country,
|
||||
Ethnicity: ethnicity,
|
||||
EyeColor: eyeColor,
|
||||
FakeTits: fakeTits,
|
||||
Favorite: true,
|
||||
Gender: gender,
|
||||
Height: strconv.Itoa(height),
|
||||
Instagram: instagram,
|
||||
Measurements: measurements,
|
||||
Piercings: piercings,
|
||||
Tattoos: tattoos,
|
||||
Twitter: twitter,
|
||||
CreatedAt: json.JSONTime{
|
||||
Time: createTime,
|
||||
},
|
||||
UpdatedAt: json.JSONTime{
|
||||
Time: updateTime,
|
||||
},
|
||||
Rating: rating,
|
||||
Image: image,
|
||||
Details: details,
|
||||
DeathDate: deathDate.String(),
|
||||
HairColor: hairColor,
|
||||
Weight: weight,
|
||||
StashIDs: []models.StashID{
|
||||
stashID,
|
||||
},
|
||||
Rating: rating,
|
||||
Image: image,
|
||||
Details: details,
|
||||
DeathDate: deathDate.String(),
|
||||
HairColor: hairColor,
|
||||
Weight: weight,
|
||||
StashIDs: stashIDs,
|
||||
IgnoreAutoTag: autoTagIgnored,
|
||||
}
|
||||
}
|
||||
|
||||
func createEmptyJSONPerformer() *jsonschema.Performer {
|
||||
return &jsonschema.Performer{
|
||||
Aliases: []string{},
|
||||
StashIDs: []models.StashID{},
|
||||
CreatedAt: json.JSONTime{
|
||||
Time: createTime,
|
||||
},
|
||||
@@ -196,9 +202,6 @@ func TestToJSON(t *testing.T) {
|
||||
mockPerformerReader.On("GetImage", testCtx, noImageID).Return(nil, nil).Once()
|
||||
mockPerformerReader.On("GetImage", testCtx, errImageID).Return(nil, imageErr).Once()
|
||||
|
||||
mockPerformerReader.On("GetStashIDs", testCtx, performerID).Return(stashIDs, nil).Once()
|
||||
mockPerformerReader.On("GetStashIDs", testCtx, noImageID).Return(nil, nil).Once()
|
||||
|
||||
for i, s := range scenarios {
|
||||
tag := s.input
|
||||
json, err := ToJSON(testCtx, mockPerformerReader, &tag)
|
||||
|
||||
Reference in New Issue
Block a user