Skip to content

Commit

Permalink
Remove deprecated fields from filters
Browse files Browse the repository at this point in the history
  • Loading branch information
WithoutPants committed Oct 16, 2023
1 parent e091895 commit f8dc75f
Show file tree
Hide file tree
Showing 21 changed files with 11 additions and 502 deletions.
31 changes: 0 additions & 31 deletions graphql/schema/types/filters.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions internal/dlna/cds.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
}

Expand Down
2 changes: 0 additions & 2 deletions pkg/models/gallery.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions pkg/models/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions pkg/models/movie.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions pkg/models/performer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions pkg/models/scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions pkg/models/studio.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 0 additions & 19 deletions pkg/sqlite/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 0 additions & 2 deletions pkg/sqlite/gallery.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
48 changes: 0 additions & 48 deletions pkg/sqlite/gallery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 0 additions & 2 deletions pkg/sqlite/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
48 changes: 0 additions & 48 deletions pkg/sqlite/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 0 additions & 2 deletions pkg/sqlite/movies.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
2 changes: 0 additions & 2 deletions pkg/sqlite/performer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
44 changes: 0 additions & 44 deletions pkg/sqlite/performer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 0 additions & 2 deletions pkg/sqlite/scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
Loading

0 comments on commit f8dc75f

Please sign in to comment.