From f8dc75f4183c5e808ca5775fc3dce0b562004c81 Mon Sep 17 00:00:00 2001 From: WithoutPants <53250216+WithoutPants@users.noreply.github.com> Date: Mon, 28 Aug 2023 14:31:52 +1000 Subject: [PATCH] Remove deprecated fields from filters --- graphql/schema/types/filters.graphql | 31 --- internal/dlna/cds.go | 4 +- pkg/models/gallery.go | 2 - pkg/models/image.go | 2 - pkg/models/movie.go | 2 - pkg/models/performer.go | 2 - pkg/models/scene.go | 2 - pkg/models/studio.go | 2 - pkg/sqlite/filter.go | 19 -- pkg/sqlite/gallery.go | 2 - pkg/sqlite/gallery_test.go | 48 ----- pkg/sqlite/image.go | 2 - pkg/sqlite/image_test.go | 48 ----- pkg/sqlite/movies.go | 2 - pkg/sqlite/performer.go | 2 - pkg/sqlite/performer_test.go | 44 ---- pkg/sqlite/scene.go | 2 - pkg/sqlite/scene_test.go | 45 ----- pkg/sqlite/studio.go | 2 - pkg/sqlite/studio_test.go | 6 +- ui/v2.5/src/components/Tagger/queries.ts | 244 +---------------------- 21 files changed, 11 insertions(+), 502 deletions(-) diff --git a/graphql/schema/types/filters.graphql b/graphql/schema/types/filters.graphql index 6e3b4f038f3..9d1f5ebe646 100644 --- a/graphql/schema/types/filters.graphql +++ b/graphql/schema/types/filters.graphql @@ -98,8 +98,6 @@ input PerformerFilterType { country: StringCriterionInput "Filter by eye color" eye_color: StringCriterionInput - "Filter by height" - height: StringCriterionInput @deprecated(reason: "Use height_cm instead") "Filter by height in cm" height_cm: IntCriterionInput "Filter by measurements" @@ -135,13 +133,7 @@ input PerformerFilterType { "Filter by o count" o_counter: IntCriterionInput "Filter by StashID" - stash_id: StringCriterionInput - @deprecated(reason: "Use stash_id_endpoint instead") - "Filter by StashID" stash_id_endpoint: StashIDCriterionInput - "Filter by rating" - rating: IntCriterionInput - @deprecated(reason: "Use 1-100 range with rating100") # rating expressed as 1-100 rating100: IntCriterionInput "Filter by url" @@ -169,8 +161,6 @@ input PerformerFilterType { } input SceneMarkerFilterType { - "Filter to only include scene markers with this tag" - tag_id: ID @deprecated(reason: "use tags filter instead") "Filter to only include scene markers with these tags" tags: HierarchicalMultiCriterionInput "Filter to only include scene markers attached to a scene with these tags" @@ -212,9 +202,6 @@ input SceneFilterType { path: StringCriterionInput "Filter by file count" file_count: IntCriterionInput - "Filter by rating" - rating: IntCriterionInput - @deprecated(reason: "Use 1-100 range with rating100") # rating expressed as 1-100 rating100: IntCriterionInput "Filter by organized" @@ -256,9 +243,6 @@ input SceneFilterType { "Filter by performer count" performer_count: IntCriterionInput "Filter by StashID" - stash_id: StringCriterionInput - @deprecated(reason: "Use stash_id_endpoint instead") - "Filter by StashID" stash_id_endpoint: StashIDCriterionInput "Filter by url" url: StringCriterionInput @@ -289,9 +273,6 @@ input MovieFilterType { "Filter by duration (in seconds)" duration: IntCriterionInput - "Filter by rating" - rating: IntCriterionInput - @deprecated(reason: "Use 1-100 range with rating100") # rating expressed as 1-100 rating100: IntCriterionInput "Filter to only include movies with this studio" @@ -320,15 +301,9 @@ input StudioFilterType { "Filter to only include studios with this parent studio" parents: MultiCriterionInput "Filter by StashID" - stash_id: StringCriterionInput - @deprecated(reason: "Use stash_id_endpoint instead") - "Filter by StashID" stash_id_endpoint: StashIDCriterionInput "Filter to only include studios missing this property" is_missing: String - "Filter by rating" - rating: IntCriterionInput - @deprecated(reason: "Use 1-100 range with rating100") # rating expressed as 1-100 rating100: IntCriterionInput "Filter by scene count" @@ -368,9 +343,6 @@ input GalleryFilterType { is_missing: String "Filter to include/exclude galleries that were created from zip" is_zip: Boolean - "Filter by rating" - rating: IntCriterionInput - @deprecated(reason: "Use 1-100 range with rating100") # rating expressed as 1-100 rating100: IntCriterionInput "Filter by organized" @@ -476,9 +448,6 @@ input ImageFilterType { path: StringCriterionInput "Filter by file count" file_count: IntCriterionInput - "Filter by rating" - rating: IntCriterionInput - @deprecated(reason: "Use 1-100 range with rating100") # rating expressed as 1-100 rating100: IntCriterionInput "Filter by date" diff --git a/internal/dlna/cds.go b/internal/dlna/cds.go index a23f2177cfe..2067af19d74 100644 --- a/internal/dlna/cds.go +++ b/internal/dlna/cds.go @@ -717,9 +717,9 @@ func (me *contentDirectoryService) getRatingScenes(paths []string, host string) } sceneFilter := &models.SceneFilterType{ - Rating: &models.IntCriterionInput{ + Rating100: &models.IntCriterionInput{ Modifier: models.CriterionModifierEquals, - Value: r, + Value: models.Rating5To100(r), }, } diff --git a/pkg/models/gallery.go b/pkg/models/gallery.go index 8c19f5e26d4..bdff9c7fb51 100644 --- a/pkg/models/gallery.go +++ b/pkg/models/gallery.go @@ -17,8 +17,6 @@ type GalleryFilterType struct { IsMissing *string `json:"is_missing"` // Filter to include/exclude galleries that were created from zip IsZip *bool `json:"is_zip"` - // Filter by rating expressed as 1-5 - Rating *IntCriterionInput `json:"rating"` // Filter by rating expressed as 1-100 Rating100 *IntCriterionInput `json:"rating100"` // Filter by organized diff --git a/pkg/models/image.go b/pkg/models/image.go index ef90dfd7d69..25d227f329d 100644 --- a/pkg/models/image.go +++ b/pkg/models/image.go @@ -14,8 +14,6 @@ type ImageFilterType struct { Path *StringCriterionInput `json:"path"` // Filter by file count FileCount *IntCriterionInput `json:"file_count"` - // Filter by rating expressed as 1-5 - Rating *IntCriterionInput `json:"rating"` // Filter by rating expressed as 1-100 Rating100 *IntCriterionInput `json:"rating100"` // Filter by date diff --git a/pkg/models/movie.go b/pkg/models/movie.go index be7effad376..c4afab0e507 100644 --- a/pkg/models/movie.go +++ b/pkg/models/movie.go @@ -6,8 +6,6 @@ type MovieFilterType struct { Synopsis *StringCriterionInput `json:"synopsis"` // Filter by duration (in seconds) Duration *IntCriterionInput `json:"duration"` - // Filter by rating expressed as 1-5 - Rating *IntCriterionInput `json:"rating"` // Filter by rating expressed as 1-100 Rating100 *IntCriterionInput `json:"rating100"` // Filter to only include movies with this studio diff --git a/pkg/models/performer.go b/pkg/models/performer.go index 0555abdcd91..f2bab92fd08 100644 --- a/pkg/models/performer.go +++ b/pkg/models/performer.go @@ -165,8 +165,6 @@ type PerformerFilterType struct { StashID *StringCriterionInput `json:"stash_id"` // Filter by StashID Endpoint StashIDEndpoint *StashIDCriterionInput `json:"stash_id_endpoint"` - // Filter by rating expressed as 1-5 - Rating *IntCriterionInput `json:"rating"` // Filter by rating expressed as 1-100 Rating100 *IntCriterionInput `json:"rating100"` // Filter by url diff --git a/pkg/models/scene.go b/pkg/models/scene.go index 3e1b3c16d74..748457a8440 100644 --- a/pkg/models/scene.go +++ b/pkg/models/scene.go @@ -29,8 +29,6 @@ type SceneFilterType struct { Path *StringCriterionInput `json:"path"` // Filter by file count FileCount *IntCriterionInput `json:"file_count"` - // Filter by rating expressed as 1-5 - Rating *IntCriterionInput `json:"rating"` // Filter by rating expressed as 1-100 Rating100 *IntCriterionInput `json:"rating100"` // Filter by organized diff --git a/pkg/models/studio.go b/pkg/models/studio.go index a9d4bd862ce..3b38cf40924 100644 --- a/pkg/models/studio.go +++ b/pkg/models/studio.go @@ -14,8 +14,6 @@ type StudioFilterType struct { StashIDEndpoint *StashIDCriterionInput `json:"stash_id_endpoint"` // Filter to only include studios missing this property IsMissing *string `json:"is_missing"` - // Filter by rating expressed as 1-5 - Rating *IntCriterionInput `json:"rating"` // Filter by rating expressed as 1-100 Rating100 *IntCriterionInput `json:"rating100"` // Filter by scene count diff --git a/pkg/sqlite/filter.go b/pkg/sqlite/filter.go index 3bb05ba0c99..16a863ae793 100644 --- a/pkg/sqlite/filter.go +++ b/pkg/sqlite/filter.go @@ -575,25 +575,6 @@ func boolCriterionHandler(c *bool, column string, addJoinFn func(f *filterBuilde } } -func rating5CriterionHandler(c *models.IntCriterionInput, column string, addJoinFn func(f *filterBuilder)) criterionHandlerFunc { - return func(ctx context.Context, f *filterBuilder) { - if c != nil { - // make a copy so we can adjust it - cc := *c - if cc.Value != 0 { - cc.Value = models.Rating5To100(cc.Value) - } - if cc.Value2 != nil { - val := models.Rating5To100(*cc.Value2) - cc.Value2 = &val - } - - clause, args := getIntCriterionWhereClause(column, cc) - f.addWhere(clause, args...) - } - } -} - func dateCriterionHandler(c *models.DateCriterionInput, column string) criterionHandlerFunc { return func(ctx context.Context, f *filterBuilder) { if c != nil { diff --git a/pkg/sqlite/gallery.go b/pkg/sqlite/gallery.go index 41729c9ad95..371aca324ea 100644 --- a/pkg/sqlite/gallery.go +++ b/pkg/sqlite/gallery.go @@ -681,8 +681,6 @@ func (qb *GalleryStore) makeFilter(ctx context.Context, galleryFilter *models.Ga query.handleCriterion(ctx, qb.galleryPathCriterionHandler(galleryFilter.Path)) query.handleCriterion(ctx, galleryFileCountCriterionHandler(qb, galleryFilter.FileCount)) query.handleCriterion(ctx, intCriterionHandler(galleryFilter.Rating100, "galleries.rating", nil)) - // legacy rating handler - query.handleCriterion(ctx, rating5CriterionHandler(galleryFilter.Rating, "galleries.rating", nil)) query.handleCriterion(ctx, galleryURLsCriterionHandler(galleryFilter.URL)) query.handleCriterion(ctx, boolCriterionHandler(galleryFilter.Organized, "galleries.organized", nil)) query.handleCriterion(ctx, galleryIsMissingCriterionHandler(qb, galleryFilter.IsMissing)) diff --git a/pkg/sqlite/gallery_test.go b/pkg/sqlite/gallery_test.go index 9b1075ecaed..5a7c5088c85 100644 --- a/pkg/sqlite/gallery_test.go +++ b/pkg/sqlite/gallery_test.go @@ -1715,54 +1715,6 @@ func verifyGalleryQuery(t *testing.T, filter models.GalleryFilterType, verifyFn }) } -func TestGalleryQueryLegacyRating(t *testing.T) { - const rating = 3 - ratingCriterion := models.IntCriterionInput{ - Value: rating, - Modifier: models.CriterionModifierEquals, - } - - verifyGalleriesLegacyRating(t, ratingCriterion) - - ratingCriterion.Modifier = models.CriterionModifierNotEquals - verifyGalleriesLegacyRating(t, ratingCriterion) - - ratingCriterion.Modifier = models.CriterionModifierGreaterThan - verifyGalleriesLegacyRating(t, ratingCriterion) - - ratingCriterion.Modifier = models.CriterionModifierLessThan - verifyGalleriesLegacyRating(t, ratingCriterion) - - ratingCriterion.Modifier = models.CriterionModifierIsNull - verifyGalleriesLegacyRating(t, ratingCriterion) - - ratingCriterion.Modifier = models.CriterionModifierNotNull - verifyGalleriesLegacyRating(t, ratingCriterion) -} - -func verifyGalleriesLegacyRating(t *testing.T, ratingCriterion models.IntCriterionInput) { - withTxn(func(ctx context.Context) error { - sqb := db.Gallery - galleryFilter := models.GalleryFilterType{ - Rating: &ratingCriterion, - } - - galleries, _, err := sqb.Query(ctx, &galleryFilter, nil) - if err != nil { - t.Errorf("Error querying gallery: %s", err.Error()) - } - - // convert criterion value to the 100 value - ratingCriterion.Value = models.Rating5To100(ratingCriterion.Value) - - for _, gallery := range galleries { - verifyIntPtr(t, gallery.Rating, ratingCriterion) - } - - return nil - }) -} - func TestGalleryQueryRating100(t *testing.T) { const rating = 60 ratingCriterion := models.IntCriterionInput{ diff --git a/pkg/sqlite/image.go b/pkg/sqlite/image.go index 5de7ea607ba..7a2e58ca498 100644 --- a/pkg/sqlite/image.go +++ b/pkg/sqlite/image.go @@ -676,8 +676,6 @@ func (qb *ImageStore) makeFilter(ctx context.Context, imageFilter *models.ImageF query.handleCriterion(ctx, pathCriterionHandler(imageFilter.Path, "folders.path", "files.basename", qb.addFoldersTable)) query.handleCriterion(ctx, imageFileCountCriterionHandler(qb, imageFilter.FileCount)) query.handleCriterion(ctx, intCriterionHandler(imageFilter.Rating100, "images.rating", nil)) - // legacy rating handler - query.handleCriterion(ctx, rating5CriterionHandler(imageFilter.Rating, "images.rating", nil)) query.handleCriterion(ctx, intCriterionHandler(imageFilter.OCounter, "images.o_counter", nil)) query.handleCriterion(ctx, boolCriterionHandler(imageFilter.Organized, "images.organized", nil)) query.handleCriterion(ctx, dateCriterionHandler(imageFilter.Date, "images.date")) diff --git a/pkg/sqlite/image_test.go b/pkg/sqlite/image_test.go index 7735cb5ec43..5f06dd401cd 100644 --- a/pkg/sqlite/image_test.go +++ b/pkg/sqlite/image_test.go @@ -1772,54 +1772,6 @@ func TestImageIllegalQuery(t *testing.T) { }) } -func TestImageQueryLegacyRating(t *testing.T) { - const rating = 3 - ratingCriterion := models.IntCriterionInput{ - Value: rating, - Modifier: models.CriterionModifierEquals, - } - - verifyImagesLegacyRating(t, ratingCriterion) - - ratingCriterion.Modifier = models.CriterionModifierNotEquals - verifyImagesLegacyRating(t, ratingCriterion) - - ratingCriterion.Modifier = models.CriterionModifierGreaterThan - verifyImagesLegacyRating(t, ratingCriterion) - - ratingCriterion.Modifier = models.CriterionModifierLessThan - verifyImagesLegacyRating(t, ratingCriterion) - - ratingCriterion.Modifier = models.CriterionModifierIsNull - verifyImagesLegacyRating(t, ratingCriterion) - - ratingCriterion.Modifier = models.CriterionModifierNotNull - verifyImagesLegacyRating(t, ratingCriterion) -} - -func verifyImagesLegacyRating(t *testing.T, ratingCriterion models.IntCriterionInput) { - withTxn(func(ctx context.Context) error { - sqb := db.Image - imageFilter := models.ImageFilterType{ - Rating: &ratingCriterion, - } - - images, _, err := queryImagesWithCount(ctx, sqb, &imageFilter, nil) - if err != nil { - t.Errorf("Error querying image: %s", err.Error()) - } - - // convert criterion value to the 100 value - ratingCriterion.Value = models.Rating5To100(ratingCriterion.Value) - - for _, image := range images { - verifyIntPtr(t, image.Rating, ratingCriterion) - } - - return nil - }) -} - func TestImageQueryRating100(t *testing.T) { const rating = 60 ratingCriterion := models.IntCriterionInput{ diff --git a/pkg/sqlite/movies.go b/pkg/sqlite/movies.go index adc7fe29eee..169ee9885de 100644 --- a/pkg/sqlite/movies.go +++ b/pkg/sqlite/movies.go @@ -334,8 +334,6 @@ func (qb *MovieStore) makeFilter(ctx context.Context, movieFilter *models.MovieF query.handleCriterion(ctx, stringCriterionHandler(movieFilter.Director, "movies.director")) query.handleCriterion(ctx, stringCriterionHandler(movieFilter.Synopsis, "movies.synopsis")) query.handleCriterion(ctx, intCriterionHandler(movieFilter.Rating100, "movies.rating", nil)) - // legacy rating handler - query.handleCriterion(ctx, rating5CriterionHandler(movieFilter.Rating, "movies.rating", nil)) query.handleCriterion(ctx, floatIntCriterionHandler(movieFilter.Duration, "movies.duration", nil)) query.handleCriterion(ctx, movieIsMissingCriterionHandler(qb, movieFilter.IsMissing)) query.handleCriterion(ctx, stringCriterionHandler(movieFilter.URL, "movies.url")) diff --git a/pkg/sqlite/performer.go b/pkg/sqlite/performer.go index 15a5f384a4a..758faad20fc 100644 --- a/pkg/sqlite/performer.go +++ b/pkg/sqlite/performer.go @@ -636,8 +636,6 @@ func (qb *PerformerStore) makeFilter(ctx context.Context, filter *models.Perform query.handleCriterion(ctx, stringCriterionHandler(filter.Tattoos, tableName+".tattoos")) query.handleCriterion(ctx, stringCriterionHandler(filter.Piercings, tableName+".piercings")) query.handleCriterion(ctx, intCriterionHandler(filter.Rating100, tableName+".rating", nil)) - // legacy rating handler - query.handleCriterion(ctx, rating5CriterionHandler(filter.Rating, tableName+".rating", nil)) query.handleCriterion(ctx, stringCriterionHandler(filter.HairColor, tableName+".hair_color")) query.handleCriterion(ctx, stringCriterionHandler(filter.URL, tableName+".url")) query.handleCriterion(ctx, intCriterionHandler(filter.Weight, tableName+".weight", nil)) diff --git a/pkg/sqlite/performer_test.go b/pkg/sqlite/performer_test.go index 6752f199f57..1951d4eb750 100644 --- a/pkg/sqlite/performer_test.go +++ b/pkg/sqlite/performer_test.go @@ -1719,50 +1719,6 @@ func testPerformerStashIDs(ctx context.Context, t *testing.T, s *models.Performe assert.Len(t, s.StashIDs.List(), 0) } -func TestPerformerQueryLegacyRating(t *testing.T) { - const rating = 3 - ratingCriterion := models.IntCriterionInput{ - Value: rating, - Modifier: models.CriterionModifierEquals, - } - - verifyPerformersLegacyRating(t, ratingCriterion) - - ratingCriterion.Modifier = models.CriterionModifierNotEquals - verifyPerformersLegacyRating(t, ratingCriterion) - - ratingCriterion.Modifier = models.CriterionModifierGreaterThan - verifyPerformersLegacyRating(t, ratingCriterion) - - ratingCriterion.Modifier = models.CriterionModifierLessThan - verifyPerformersLegacyRating(t, ratingCriterion) - - ratingCriterion.Modifier = models.CriterionModifierIsNull - verifyPerformersLegacyRating(t, ratingCriterion) - - ratingCriterion.Modifier = models.CriterionModifierNotNull - verifyPerformersLegacyRating(t, ratingCriterion) -} - -func verifyPerformersLegacyRating(t *testing.T, ratingCriterion models.IntCriterionInput) { - withTxn(func(ctx context.Context) error { - performerFilter := models.PerformerFilterType{ - Rating: &ratingCriterion, - } - - performers := queryPerformers(ctx, t, &performerFilter, nil) - - // convert criterion value to the 100 value - ratingCriterion.Value = models.Rating5To100(ratingCriterion.Value) - - for _, performer := range performers { - verifyIntPtr(t, performer.Rating, ratingCriterion) - } - - return nil - }) -} - func TestPerformerQueryRating100(t *testing.T) { const rating = 60 ratingCriterion := models.IntCriterionInput{ diff --git a/pkg/sqlite/scene.go b/pkg/sqlite/scene.go index d898dc7ee15..74a2b2651be 100644 --- a/pkg/sqlite/scene.go +++ b/pkg/sqlite/scene.go @@ -976,8 +976,6 @@ func (qb *SceneStore) makeFilter(ctx context.Context, sceneFilter *models.SceneF query.handleCriterion(ctx, scenePhashDistanceCriterionHandler(qb, sceneFilter.PhashDistance)) query.handleCriterion(ctx, intCriterionHandler(sceneFilter.Rating100, "scenes.rating", nil)) - // legacy rating handler - query.handleCriterion(ctx, rating5CriterionHandler(sceneFilter.Rating, "scenes.rating", nil)) query.handleCriterion(ctx, intCriterionHandler(sceneFilter.OCounter, "scenes.o_counter", nil)) query.handleCriterion(ctx, boolCriterionHandler(sceneFilter.Organized, "scenes.organized", nil)) diff --git a/pkg/sqlite/scene_test.go b/pkg/sqlite/scene_test.go index 0da236f4d7d..a3fb5eeed0a 100644 --- a/pkg/sqlite/scene_test.go +++ b/pkg/sqlite/scene_test.go @@ -2673,51 +2673,6 @@ func verifyString(t *testing.T, value string, criterion models.StringCriterionIn } } -func TestSceneQueryRating(t *testing.T) { - const rating = 3 - ratingCriterion := models.IntCriterionInput{ - Value: rating, - Modifier: models.CriterionModifierEquals, - } - - verifyScenesLegacyRating(t, ratingCriterion) - - ratingCriterion.Modifier = models.CriterionModifierNotEquals - verifyScenesLegacyRating(t, ratingCriterion) - - ratingCriterion.Modifier = models.CriterionModifierGreaterThan - verifyScenesLegacyRating(t, ratingCriterion) - - ratingCriterion.Modifier = models.CriterionModifierLessThan - verifyScenesLegacyRating(t, ratingCriterion) - - ratingCriterion.Modifier = models.CriterionModifierIsNull - verifyScenesLegacyRating(t, ratingCriterion) - - ratingCriterion.Modifier = models.CriterionModifierNotNull - verifyScenesLegacyRating(t, ratingCriterion) -} - -func verifyScenesLegacyRating(t *testing.T, ratingCriterion models.IntCriterionInput) { - withTxn(func(ctx context.Context) error { - sqb := db.Scene - sceneFilter := models.SceneFilterType{ - Rating: &ratingCriterion, - } - - scenes := queryScene(ctx, t, sqb, &sceneFilter, nil) - - // convert criterion value to the 100 value - ratingCriterion.Value = models.Rating5To100(ratingCriterion.Value) - - for _, scene := range scenes { - verifyIntPtr(t, scene.Rating, ratingCriterion) - } - - return nil - }) -} - func TestSceneQueryRating100(t *testing.T) { const rating = 60 ratingCriterion := models.IntCriterionInput{ diff --git a/pkg/sqlite/studio.go b/pkg/sqlite/studio.go index 17fbf1fdc10..fec08ed4550 100644 --- a/pkg/sqlite/studio.go +++ b/pkg/sqlite/studio.go @@ -496,8 +496,6 @@ func (qb *StudioStore) makeFilter(ctx context.Context, studioFilter *models.Stud query.handleCriterion(ctx, stringCriterionHandler(studioFilter.Details, studioTable+".details")) query.handleCriterion(ctx, stringCriterionHandler(studioFilter.URL, studioTable+".url")) query.handleCriterion(ctx, intCriterionHandler(studioFilter.Rating100, studioTable+".rating", nil)) - // legacy rating handler - query.handleCriterion(ctx, rating5CriterionHandler(studioFilter.Rating, studioTable+".rating", nil)) query.handleCriterion(ctx, boolCriterionHandler(studioFilter.IgnoreAutoTag, studioTable+".ignore_auto_tag", nil)) query.handleCriterion(ctx, criterionHandlerFunc(func(ctx context.Context, f *filterBuilder) { diff --git a/pkg/sqlite/studio_test.go b/pkg/sqlite/studio_test.go index 8e3bfb85432..25f8ea195d3 100644 --- a/pkg/sqlite/studio_test.go +++ b/pkg/sqlite/studio_test.go @@ -672,7 +672,7 @@ func TestStudioQueryURL(t *testing.T) { } func TestStudioQueryRating(t *testing.T) { - const rating = 3 + const rating = 60 ratingCriterion := models.IntCriterionInput{ Value: rating, Modifier: models.CriterionModifierEquals, @@ -718,7 +718,7 @@ func verifyStudiosRating(t *testing.T, ratingCriterion models.IntCriterionInput) withTxn(func(ctx context.Context) error { sqb := db.Studio studioFilter := models.StudioFilterType{ - Rating: &ratingCriterion, + Rating100: &ratingCriterion, } studios, _, err := sqb.Query(ctx, &studioFilter, nil) @@ -959,7 +959,7 @@ func TestStudioQueryFast(t *testing.T) { URL: &testStringCriterion, } ratingFilter := models.StudioFilterType{ - Rating: &testIntCriterion, + Rating100: &testIntCriterion, } sceneCountFilter := models.StudioFilterType{ SceneCount: &testIntCriterion, diff --git a/ui/v2.5/src/components/Tagger/queries.ts b/ui/v2.5/src/components/Tagger/queries.ts index 4a64481741d..734a6f736be 100644 --- a/ui/v2.5/src/components/Tagger/queries.ts +++ b/ui/v2.5/src/components/Tagger/queries.ts @@ -1,61 +1,10 @@ import * as GQL from "src/core/generated-graphql"; -import sortBy from "lodash-es/sortBy"; import { evictQueries, getClient, studioMutationImpactedQueries, } from "src/core/StashService"; -export const useUpdatePerformerStashID = () => { - const [updatePerformer] = GQL.usePerformerUpdateMutation({ - onError: (errors) => errors, - }); - - const updatePerformerHandler = ( - performerID: string, - stashIDs: GQL.StashIdInput[] - ) => - updatePerformer({ - variables: { - input: { - id: performerID, - stash_ids: stashIDs.map((s) => ({ - stash_id: s.stash_id, - endpoint: s.endpoint, - })), - }, - }, - update: (store, updatedPerformer) => { - if (!updatedPerformer.data?.performerUpdate) return; - const newStashID = stashIDs[stashIDs.length - 1].stash_id; - - store.writeQuery< - GQL.FindPerformersQuery, - GQL.FindPerformersQueryVariables - >({ - query: GQL.FindPerformersDocument, - variables: { - performer_filter: { - stash_id: { - value: newStashID, - modifier: GQL.CriterionModifier.Equals, - }, - }, - }, - data: { - findPerformers: { - count: 1, - performers: [updatedPerformer.data.performerUpdate], - __typename: "FindPerformersResultType", - }, - }, - }); - }, - }); - - return updatePerformerHandler; -}; - export const useUpdatePerformer = () => { const [updatePerformer] = GQL.usePerformerUpdateMutation({ onError: (errors) => errors, @@ -78,8 +27,9 @@ export const useUpdatePerformer = () => { query: GQL.FindPerformersDocument, variables: { performer_filter: { - stash_id: { - value: id.stash_id, + stash_id_endpoint: { + stash_id: id.stash_id, + endpoint: id.endpoint, modifier: GQL.CriterionModifier.Equals, }, }, @@ -99,91 +49,6 @@ export const useUpdatePerformer = () => { return updatePerformerHandler; }; -export const useCreatePerformer = () => { - const [createPerformer] = GQL.usePerformerCreateMutation({ - onError: (errors) => errors, - }); - - const handleCreate = (performer: GQL.PerformerCreateInput, stashID: string) => - createPerformer({ - variables: { input: performer }, - update: (store, newPerformer) => { - if (!newPerformer?.data?.performerCreate) return; - - store.writeQuery< - GQL.FindPerformersQuery, - GQL.FindPerformersQueryVariables - >({ - query: GQL.FindPerformersDocument, - variables: { - performer_filter: { - stash_id: { - value: stashID, - modifier: GQL.CriterionModifier.Equals, - }, - }, - }, - data: { - findPerformers: { - count: 1, - performers: [newPerformer.data.performerCreate], - __typename: "FindPerformersResultType", - }, - }, - }); - }, - }); - - return handleCreate; -}; - -export const useUpdateStudioStashID = () => { - const [updateStudio] = GQL.useStudioUpdateMutation({ - onError: (errors) => errors, - }); - - const handleUpdate = ( - studio: GQL.SlimStudioDataFragment, - stashIDs: GQL.StashIdInput[] - ) => - updateStudio({ - variables: { - input: { - id: studio.id, - stash_ids: stashIDs.map((s) => ({ - stash_id: s.stash_id, - endpoint: s.endpoint, - })), - }, - }, - update: (store, result) => { - if (!result.data?.studioUpdate) return; - const newStashID = stashIDs[stashIDs.length - 1].stash_id; - - store.writeQuery({ - query: GQL.FindStudiosDocument, - variables: { - studio_filter: { - stash_id: { - value: newStashID, - modifier: GQL.CriterionModifier.Equals, - }, - }, - }, - data: { - findStudios: { - count: 1, - studios: [result.data.studioUpdate], - __typename: "FindStudiosResultType", - }, - }, - }); - }, - }); - - return handleUpdate; -}; - export const useUpdateStudio = () => { const [updateStudio] = GQL.useStudioUpdateMutation({ onError: (errors) => errors, @@ -210,8 +75,9 @@ export const useUpdateStudio = () => { query: GQL.FindStudiosDocument, variables: { studio_filter: { - stash_id: { - value: id.stash_id, + stash_id_endpoint: { + stash_id: id.stash_id, + endpoint: id.endpoint, modifier: GQL.CriterionModifier.Equals, }, }, @@ -231,101 +97,3 @@ export const useUpdateStudio = () => { return updateStudioHandler; }; - -export const useCreateStudio = () => { - const [createStudio] = GQL.useStudioCreateMutation({ - onError: (errors) => errors, - }); - - const handleCreate = (studio: GQL.StudioCreateInput, stashID: string) => - createStudio({ - variables: { input: studio }, - update: (store, result) => { - if (!result?.data?.studioCreate) return; - - const currentQuery = store.readQuery< - GQL.AllStudiosForFilterQuery, - GQL.AllStudiosForFilterQueryVariables - >({ - query: GQL.AllStudiosForFilterDocument, - }); - const allStudios = sortBy( - [...(currentQuery?.allStudios ?? []), result.data.studioCreate], - ["name"] - ); - if (allStudios.length > 1) { - store.writeQuery< - GQL.AllStudiosForFilterQuery, - GQL.AllStudiosForFilterQueryVariables - >({ - query: GQL.AllStudiosForFilterDocument, - data: { - allStudios, - }, - }); - } - - store.writeQuery({ - query: GQL.FindStudiosDocument, - variables: { - studio_filter: { - stash_id: { - value: stashID, - modifier: GQL.CriterionModifier.Equals, - }, - }, - }, - data: { - findStudios: { - count: 1, - studios: [result.data.studioCreate], - __typename: "FindStudiosResultType", - }, - }, - }); - }, - }); - - return handleCreate; -}; - -export const useCreateTag = () => { - const [createTag] = GQL.useTagCreateMutation({ - onError: (errors) => errors, - }); - - const handleCreate = (tag: string) => - createTag({ - variables: { - input: { - name: tag, - }, - }, - update: (store, result) => { - if (!result.data?.tagCreate) return; - - const currentQuery = store.readQuery< - GQL.AllTagsForFilterQuery, - GQL.AllTagsForFilterQueryVariables - >({ - query: GQL.AllTagsForFilterDocument, - }); - const allTags = sortBy( - [...(currentQuery?.allTags ?? []), result.data.tagCreate], - ["name"] - ); - - store.writeQuery< - GQL.AllTagsForFilterQuery, - GQL.AllTagsForFilterQueryVariables - >({ - query: GQL.AllTagsForFilterDocument, - data: { - allTags, - }, - }); - }, - }); - - return handleCreate; -};