Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performer disambiguation and aliases #3113

Merged
merged 28 commits into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
84adaca
Refactor performer relationships
WithoutPants Nov 2, 2022
929cc4a
Remove checksum from performer
WithoutPants Nov 2, 2022
a063fee
Add disambiguation, overhaul aliases
WithoutPants Nov 2, 2022
d38280b
Fix unique indexes
WithoutPants Nov 3, 2022
136bd85
Fix post-migration
WithoutPants Nov 3, 2022
ce2320f
Update UI for new fields
WithoutPants Nov 3, 2022
053c581
Scrape and UI fixes
WithoutPants Nov 3, 2022
239b802
Update schema number
WithoutPants Nov 10, 2022
edfb990
Fix postmigration
WithoutPants Nov 10, 2022
f5acba5
Add autotag support for performer aliases
WithoutPants Nov 10, 2022
5c3d911
Add disambiguation filter criterion
WithoutPants Nov 10, 2022
91f8d8e
Improve name matching during import
WithoutPants Nov 10, 2022
e651cd3
Add disambiguation filtering in UI
WithoutPants Nov 10, 2022
e7b7e37
Include aliases in performer select
WithoutPants Nov 10, 2022
1e8b0aa
Fix create option
WithoutPants Nov 10, 2022
b8ad71b
Include / as alias separator in migration
WithoutPants Nov 14, 2022
5d9d1ee
Merge remote-tracking branch 'upstream/develop' into performer-alias
WithoutPants Nov 15, 2022
59c366c
Fix aliases in scrape dialog
WithoutPants Nov 15, 2022
d58de80
Sort aliases in edit panel
WithoutPants Nov 15, 2022
70669ac
Improve usability of string list input
WithoutPants Nov 15, 2022
a40db6b
Merge remote-tracking branch 'upstream/develop' into performer-alias
WithoutPants Nov 16, 2022
1786474
Merge remote-tracking branch 'upstream/develop' into performer-alias
WithoutPants Nov 21, 2022
1d986cf
Fix alias filtering
WithoutPants Nov 21, 2022
731010d
Handle duplicate performer names in post-migration
WithoutPants Nov 21, 2022
4222999
Disable autotag matching on performer aliases
WithoutPants Nov 22, 2022
63e65ab
Add changelog entry
WithoutPants Nov 22, 2022
9573941
Merge remote-tracking branch 'upstream/develop' into performer-alias
WithoutPants Nov 30, 2022
4280863
Add new changelog
WithoutPants Nov 30, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions graphql/documents/data/performer-slim.graphql
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
fragment SlimPerformerData on Performer {
id
name
disambiguation
gender
url
twitter
Expand All @@ -18,6 +19,7 @@ fragment SlimPerformerData on Performer {
career_length
tattoos
piercings
alias_list
tags {
id
name
Expand Down
3 changes: 2 additions & 1 deletion graphql/documents/data/performer.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ fragment PerformerData on Performer {
id
checksum
name
disambiguation
url
gender
twitter
Expand All @@ -16,7 +17,7 @@ fragment PerformerData on Performer {
career_length
tattoos
piercings
aliases
alias_list
favorite
ignore_auto_tag
image_path
Expand Down
2 changes: 2 additions & 0 deletions graphql/documents/data/scrapers.graphql
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
fragment ScrapedPerformerData on ScrapedPerformer {
stored_id
name
disambiguation
gender
url
twitter
Expand Down Expand Up @@ -30,6 +31,7 @@ fragment ScrapedPerformerData on ScrapedPerformer {
fragment ScrapedScenePerformerData on ScrapedPerformer {
stored_id
name
disambiguation
gender
url
twitter
Expand Down
1 change: 1 addition & 0 deletions graphql/schema/types/filters.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ input PerformerFilterType {
NOT: PerformerFilterType

name: StringCriterionInput
disambiguation: StringCriterionInput
details: StringCriterionInput

"""Filter by favorite"""
Expand Down
25 changes: 19 additions & 6 deletions graphql/schema/types/performer.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ enum GenderEnum {

type Performer {
id: ID!
checksum: String!
name: String
checksum: String @deprecated(reason: "Not used")
name: String!
disambiguation: String
url: String
gender: GenderEnum
twitter: String
Expand All @@ -26,7 +27,8 @@ type Performer {
career_length: String
tattoos: String
piercings: String
aliases: String
aliases: String @deprecated(reason: "Use alias_list")
alias_list: [String!]!
favorite: Boolean!
tags: [Tag!]!
ignore_auto_tag: Boolean!
Expand All @@ -50,6 +52,7 @@ type Performer {

input PerformerCreateInput {
name: String!
disambiguation: String
url: String
gender: GenderEnum
birthdate: String
Expand All @@ -64,7 +67,8 @@ input PerformerCreateInput {
career_length: String
tattoos: String
piercings: String
aliases: String
aliases: String @deprecated(reason: "Use alias_list")
alias_list: [String!]
twitter: String
instagram: String
favorite: Boolean
Expand All @@ -83,6 +87,7 @@ input PerformerCreateInput {
input PerformerUpdateInput {
id: ID!
name: String
disambiguation: String
url: String
gender: GenderEnum
birthdate: String
Expand All @@ -97,7 +102,8 @@ input PerformerUpdateInput {
career_length: String
tattoos: String
piercings: String
aliases: String
aliases: String @deprecated(reason: "Use alias_list")
alias_list: [String!]
twitter: String
instagram: String
favorite: Boolean
Expand All @@ -113,9 +119,15 @@ input PerformerUpdateInput {
ignore_auto_tag: Boolean
}

input BulkUpdateStrings {
values: [String!]
mode: BulkUpdateIdMode!
}

input BulkPerformerUpdateInput {
clientMutationId: String
ids: [ID!]
disambiguation: String
url: String
gender: GenderEnum
birthdate: String
Expand All @@ -130,7 +142,8 @@ input BulkPerformerUpdateInput {
career_length: String
tattoos: String
piercings: String
aliases: String
aliases: String @deprecated(reason: "Use alias_list")
alias_list: BulkUpdateStrings
twitter: String
instagram: String
favorite: Boolean
Expand Down
3 changes: 3 additions & 0 deletions graphql/schema/types/scraped-performer.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ type ScrapedPerformer {
"""Set if performer matched"""
stored_id: ID
name: String
disambiguation: String
gender: String
url: String
twitter: String
Expand All @@ -17,6 +18,7 @@ type ScrapedPerformer {
career_length: String
tattoos: String
piercings: String
# aliases must be comma-delimited to be parsed correctly
aliases: String
tags: [ScrapedTag!]

Expand All @@ -34,6 +36,7 @@ input ScrapedPerformerInput {
"""Set if performer matched"""
stored_id: ID
name: String
disambiguation: String
gender: String
url: String
twitter: String
Expand Down
54 changes: 43 additions & 11 deletions internal/api/resolver_model_performer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,45 @@ package api
import (
"context"
"strconv"
"strings"

"github.com/stashapp/stash/internal/api/loaders"
"github.com/stashapp/stash/internal/api/urlbuilders"
"github.com/stashapp/stash/pkg/gallery"
"github.com/stashapp/stash/pkg/image"
"github.com/stashapp/stash/pkg/models"
)

// Checksum is deprecated
func (r *performerResolver) Checksum(ctx context.Context, obj *models.Performer) (*string, error) {
return nil, nil
}

func (r *performerResolver) Aliases(ctx context.Context, obj *models.Performer) (*string, error) {
if !obj.Aliases.Loaded() {
if err := r.withTxn(ctx, func(ctx context.Context) error {
return obj.LoadAliases(ctx, r.repository.Performer)
}); err != nil {
return nil, err
}
}

ret := strings.Join(obj.Aliases.List(), ", ")
return &ret, nil
}

func (r *performerResolver) AliasList(ctx context.Context, obj *models.Performer) ([]string, error) {
if !obj.Aliases.Loaded() {
if err := r.withTxn(ctx, func(ctx context.Context) error {
return obj.LoadAliases(ctx, r.repository.Performer)
}); err != nil {
return nil, err
}
}

return obj.Aliases.List(), nil
}

func (r *performerResolver) Height(ctx context.Context, obj *models.Performer) (*string, error) {
if obj.Height != nil {
ret := strconv.Itoa(*obj.Height)
Expand Down Expand Up @@ -37,14 +69,17 @@ func (r *performerResolver) ImagePath(ctx context.Context, obj *models.Performer
}

func (r *performerResolver) Tags(ctx context.Context, obj *models.Performer) (ret []*models.Tag, err error) {
if err := r.withTxn(ctx, func(ctx context.Context) error {
ret, err = r.repository.Tag.FindByPerformerID(ctx, obj.ID)
return err
}); err != nil {
return nil, err
if !obj.TagIDs.Loaded() {
if err := r.withTxn(ctx, func(ctx context.Context) error {
return obj.LoadTagIDs(ctx, r.repository.Performer)
}); err != nil {
return nil, err
}
}

return ret, nil
var errs []error
ret, errs = loaders.From(ctx).TagByID.LoadAll(obj.TagIDs.List())
return ret, firstError(errs)
}

func (r *performerResolver) SceneCount(ctx context.Context, obj *models.Performer) (ret *int, err error) {
Expand Down Expand Up @@ -95,16 +130,13 @@ func (r *performerResolver) Scenes(ctx context.Context, obj *models.Performer) (
}

func (r *performerResolver) StashIds(ctx context.Context, obj *models.Performer) ([]*models.StashID, error) {
var ret []models.StashID
if err := r.withTxn(ctx, func(ctx context.Context) error {
var err error
ret, err = r.repository.Performer.GetStashIDs(ctx, obj.ID)
return err
return obj.LoadStashIDs(ctx, r.repository.Performer)
}); err != nil {
return nil, err
}

return stashIDsSliceToPtrSlice(ret), nil
return stashIDsSliceToPtrSlice(obj.StashIDs.List()), nil
}

func (r *performerResolver) DeathDate(ctx context.Context, obj *models.Performer) (*string, error) {
Expand Down
Loading