From cdaa19115569153f7b13055f131b1d4ca4a3f729 Mon Sep 17 00:00:00 2001 From: InfiniteTF Date: Mon, 18 Apr 2022 02:43:27 +0200 Subject: [PATCH] Fix submission of scene drafts without performers (#2515) --- .gqlgenc.yml | 2 + .../stashbox/graphql/generated_client.go | 306 +++++++++--------- .../stashbox/graphql/generated_models.go | 20 +- pkg/scraper/stashbox/graphql/override.go | 17 + .../components/Changelog/versions/v0150.md | 1 + 5 files changed, 177 insertions(+), 169 deletions(-) create mode 100644 pkg/scraper/stashbox/graphql/override.go diff --git a/.gqlgenc.yml b/.gqlgenc.yml index 114a9a51b..358d7798a 100644 --- a/.gqlgenc.yml +++ b/.gqlgenc.yml @@ -7,6 +7,8 @@ client: models: Date: model: github.com/99designs/gqlgen/graphql.String + SceneDraftInput: + model: github.com/stashapp/stash/pkg/scraper/stashbox/graphql.SceneDraftInput endpoint: # This points to stashdb.org currently, but can be directed at any stash-box # instance. It is used for generation only. diff --git a/pkg/scraper/stashbox/graphql/generated_client.go b/pkg/scraper/stashbox/graphql/generated_client.go index 0b701b96e..37985a20f 100644 --- a/pkg/scraper/stashbox/graphql/generated_client.go +++ b/pkg/scraper/stashbox/graphql/generated_client.go @@ -226,6 +226,20 @@ const FindSceneByFingerprintDocument = `query FindSceneByFingerprint ($fingerpri ... SceneFragment } } +fragment URLFragment on URL { + url + type +} +fragment StudioFragment on Studio { + name + id + urls { + ... URLFragment + } + images { + ... ImageFragment + } +} fragment PerformerFragment on Performer { id name @@ -260,6 +274,10 @@ fragment PerformerFragment on Performer { ... BodyModificationFragment } } +fragment FuzzyDateFragment on FuzzyDate { + date + accuracy +} fragment MeasurementsFragment on Measurements { band_size cup_size @@ -270,28 +288,6 @@ fragment BodyModificationFragment on BodyModification { location description } -fragment URLFragment on URL { - url - type -} -fragment StudioFragment on Studio { - name - id - urls { - ... URLFragment - } - images { - ... ImageFragment - } -} -fragment TagFragment on Tag { - name - id -} -fragment FuzzyDateFragment on FuzzyDate { - date - accuracy -} fragment FingerprintFragment on Fingerprint { algorithm hash @@ -328,6 +324,10 @@ fragment ImageFragment on Image { width height } +fragment TagFragment on Tag { + name + id +} fragment PerformerAppearanceFragment on PerformerAppearance { as performer { @@ -354,34 +354,19 @@ const FindScenesByFullFingerprintsDocument = `query FindScenesByFullFingerprints ... SceneFragment } } -fragment SceneFragment on Scene { +fragment URLFragment on URL { + url + type +} +fragment StudioFragment on Studio { + name id - title - details - duration - date urls { ... URLFragment } images { ... ImageFragment } - studio { - ... StudioFragment - } - tags { - ... TagFragment - } - performers { - ... PerformerAppearanceFragment - } - fingerprints { - ... FingerprintFragment - } -} -fragment URLFragment on URL { - url - type } fragment PerformerAppearanceFragment on PerformerAppearance { as @@ -427,6 +412,35 @@ fragment FuzzyDateFragment on FuzzyDate { date accuracy } +fragment SceneFragment on Scene { + id + title + details + duration + date + urls { + ... URLFragment + } + images { + ... ImageFragment + } + studio { + ... StudioFragment + } + tags { + ... TagFragment + } + performers { + ... PerformerAppearanceFragment + } + fingerprints { + ... FingerprintFragment + } +} +fragment TagFragment on Tag { + name + id +} fragment MeasurementsFragment on Measurements { band_size cup_size @@ -448,20 +462,6 @@ fragment ImageFragment on Image { width height } -fragment StudioFragment on Studio { - name - id - urls { - ... URLFragment - } - images { - ... ImageFragment - } -} -fragment TagFragment on Tag { - name - id -} ` func (c *Client) FindScenesByFullFingerprints(ctx context.Context, fingerprints []*FingerprintQueryInput, httpRequestOptions ...client.HTTPRequestOption) (*FindScenesByFullFingerprints, error) { @@ -486,15 +486,69 @@ fragment URLFragment on URL { url type } +fragment TagFragment on Tag { + name + id +} +fragment FuzzyDateFragment on FuzzyDate { + date + accuracy +} +fragment MeasurementsFragment on Measurements { + band_size + cup_size + waist + hip +} +fragment BodyModificationFragment on BodyModification { + location + description +} +fragment FingerprintFragment on Fingerprint { + algorithm + hash + duration +} +fragment SceneFragment on Scene { + id + title + details + duration + date + urls { + ... URLFragment + } + images { + ... ImageFragment + } + studio { + ... StudioFragment + } + tags { + ... TagFragment + } + performers { + ... PerformerAppearanceFragment + } + fingerprints { + ... FingerprintFragment + } +} fragment ImageFragment on Image { id url width height } -fragment TagFragment on Tag { +fragment StudioFragment on Studio { name id + urls { + ... URLFragment + } + images { + ... ImageFragment + } } fragment PerformerAppearanceFragment on PerformerAppearance { as @@ -536,60 +590,6 @@ fragment PerformerFragment on Performer { ... BodyModificationFragment } } -fragment FuzzyDateFragment on FuzzyDate { - date - accuracy -} -fragment FingerprintFragment on Fingerprint { - algorithm - hash - duration -} -fragment SceneFragment on Scene { - id - title - details - duration - date - urls { - ... URLFragment - } - images { - ... ImageFragment - } - studio { - ... StudioFragment - } - tags { - ... TagFragment - } - performers { - ... PerformerAppearanceFragment - } - fingerprints { - ... FingerprintFragment - } -} -fragment StudioFragment on Studio { - name - id - urls { - ... URLFragment - } - images { - ... ImageFragment - } -} -fragment MeasurementsFragment on Measurements { - band_size - cup_size - waist - hip -} -fragment BodyModificationFragment on BodyModification { - location - description -} ` func (c *Client) SearchScene(ctx context.Context, term string, httpRequestOptions ...client.HTTPRequestOption) (*SearchScene, error) { @@ -688,6 +688,10 @@ const FindPerformerByIDDocument = `query FindPerformerByID ($id: ID!) { ... PerformerFragment } } +fragment BodyModificationFragment on BodyModification { + location + description +} fragment PerformerFragment on Performer { id name @@ -742,10 +746,6 @@ fragment MeasurementsFragment on Measurements { waist hip } -fragment BodyModificationFragment on BodyModification { - location - description -} ` func (c *Client) FindPerformerByID(ctx context.Context, id string, httpRequestOptions ...client.HTTPRequestOption) (*FindPerformerByID, error) { @@ -766,18 +766,6 @@ const FindSceneByIDDocument = `query FindSceneByID ($id: ID!) { ... SceneFragment } } -fragment ImageFragment on Image { - id - url - width - height -} -fragment PerformerAppearanceFragment on PerformerAppearance { - as - performer { - ... PerformerFragment - } -} fragment PerformerFragment on Performer { id name @@ -812,14 +800,44 @@ fragment PerformerFragment on Performer { ... BodyModificationFragment } } -fragment FuzzyDateFragment on FuzzyDate { - date - accuracy +fragment MeasurementsFragment on Measurements { + band_size + cup_size + waist + hip } fragment BodyModificationFragment on BodyModification { location description } +fragment URLFragment on URL { + url + type +} +fragment StudioFragment on Studio { + name + id + urls { + ... URLFragment + } + images { + ... ImageFragment + } +} +fragment TagFragment on Tag { + name + id +} +fragment PerformerAppearanceFragment on PerformerAppearance { + as + performer { + ... PerformerFragment + } +} +fragment FuzzyDateFragment on FuzzyDate { + date + accuracy +} fragment FingerprintFragment on Fingerprint { algorithm hash @@ -850,29 +868,11 @@ fragment SceneFragment on Scene { ... FingerprintFragment } } -fragment URLFragment on URL { +fragment ImageFragment on Image { + id url - type -} -fragment StudioFragment on Studio { - name - id - urls { - ... URLFragment - } - images { - ... ImageFragment - } -} -fragment TagFragment on Tag { - name - id -} -fragment MeasurementsFragment on Measurements { - band_size - cup_size - waist - hip + width + height } ` diff --git a/pkg/scraper/stashbox/graphql/generated_models.go b/pkg/scraper/stashbox/graphql/generated_models.go index 910419e63..2ce0301bb 100644 --- a/pkg/scraper/stashbox/graphql/generated_models.go +++ b/pkg/scraper/stashbox/graphql/generated_models.go @@ -88,8 +88,8 @@ type DraftEntity struct { ID *string `json:"id,omitempty"` } -func (DraftEntity) IsSceneDraftStudio() {} func (DraftEntity) IsSceneDraftPerformer() {} +func (DraftEntity) IsSceneDraftStudio() {} func (DraftEntity) IsSceneDraftTag() {} type DraftEntityInput struct { @@ -348,8 +348,8 @@ type Performer struct { Updated time.Time `json:"updated"` } -func (Performer) IsEditTarget() {} func (Performer) IsSceneDraftPerformer() {} +func (Performer) IsEditTarget() {} type PerformerAppearance struct { Performer *Performer `json:"performer,omitempty"` @@ -681,18 +681,6 @@ type SceneDraft struct { func (SceneDraft) IsDraftData() {} -type SceneDraftInput struct { - Title *string `json:"title,omitempty"` - Details *string `json:"details,omitempty"` - URL *string `json:"url,omitempty"` - Date *string `json:"date,omitempty"` - Studio *DraftEntityInput `json:"studio,omitempty"` - Performers []*DraftEntityInput `json:"performers,omitempty"` - Tags []*DraftEntityInput `json:"tags,omitempty"` - Image *graphql.Upload `json:"image,omitempty"` - Fingerprints []*FingerprintInput `json:"fingerprints,omitempty"` -} - type SceneEdit struct { Title *string `json:"title,omitempty"` Details *string `json:"details,omitempty"` @@ -845,8 +833,8 @@ type Studio struct { Updated time.Time `json:"updated"` } -func (Studio) IsEditTarget() {} func (Studio) IsSceneDraftStudio() {} +func (Studio) IsEditTarget() {} type StudioCreateInput struct { Name string `json:"name"` @@ -921,8 +909,8 @@ type Tag struct { Updated time.Time `json:"updated"` } -func (Tag) IsEditTarget() {} func (Tag) IsSceneDraftTag() {} +func (Tag) IsEditTarget() {} type TagCategory struct { ID string `json:"id"` diff --git a/pkg/scraper/stashbox/graphql/override.go b/pkg/scraper/stashbox/graphql/override.go new file mode 100644 index 000000000..492a55a06 --- /dev/null +++ b/pkg/scraper/stashbox/graphql/override.go @@ -0,0 +1,17 @@ +package graphql + +import "github.com/99designs/gqlgen/graphql" + +// Override for generated struct due to mistaken omitempty +// https://github.com/Yamashou/gqlgenc/issues/77 +type SceneDraftInput struct { + Title *string `json:"title,omitempty"` + Details *string `json:"details,omitempty"` + URL *string `json:"url,omitempty"` + Date *string `json:"date,omitempty"` + Studio *DraftEntityInput `json:"studio,omitempty"` + Performers []*DraftEntityInput `json:"performers"` + Tags []*DraftEntityInput `json:"tags,omitempty"` + Image *graphql.Upload `json:"image,omitempty"` + Fingerprints []*FingerprintInput `json:"fingerprints"` +} diff --git a/ui/v2.5/src/components/Changelog/versions/v0150.md b/ui/v2.5/src/components/Changelog/versions/v0150.md index 2e7fdeb1c..466379425 100644 --- a/ui/v2.5/src/components/Changelog/versions/v0150.md +++ b/ui/v2.5/src/components/Changelog/versions/v0150.md @@ -1,2 +1,3 @@ ### 🐛 Bug fixes +* Fix error when submitting scene draft to stash-box without performers. ([#2515](https://github.com/stashapp/stash/pull/2515)) * Fix incorrect video player positioning on touch-enabled devices. ([#2501](https://github.com/stashapp/stash/issues/2501)) \ No newline at end of file