Skip to content

Commit

Permalink
Add galleries filter to scenes (#4632)
Browse files Browse the repository at this point in the history
  • Loading branch information
bob123491234 authored Mar 13, 2024
1 parent 7ac7963 commit ae6d1a8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions graphql/schema/types/filters.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ input SceneFilterType {
studios: HierarchicalMultiCriterionInput
"Filter to only include scenes with this movie"
movies: MultiCriterionInput
"Filter to only include scenes with this gallery"
galleries: MultiCriterionInput
"Filter to only include scenes with these tags"
tags: HierarchicalMultiCriterionInput
"Filter by tag count"
Expand Down
2 changes: 2 additions & 0 deletions pkg/models/scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ type SceneFilterType struct {
Studios *HierarchicalMultiCriterionInput `json:"studios"`
// Filter to only include scenes with this movie
Movies *MultiCriterionInput `json:"movies"`
// Filter to only include scenes with this gallery
Galleries *MultiCriterionInput `json:"galleries"`
// Filter to only include scenes with these tags
Tags *HierarchicalMultiCriterionInput `json:"tags"`
// Filter by tag count
Expand Down
10 changes: 10 additions & 0 deletions pkg/sqlite/scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,7 @@ func (qb *SceneStore) makeFilter(ctx context.Context, sceneFilter *models.SceneF
query.handleCriterion(ctx, scenePerformerCountCriterionHandler(qb, sceneFilter.PerformerCount))
query.handleCriterion(ctx, studioCriterionHandler(sceneTable, sceneFilter.Studios))
query.handleCriterion(ctx, sceneMoviesCriterionHandler(qb, sceneFilter.Movies))
query.handleCriterion(ctx, sceneGalleriesCriterionHandler(qb, sceneFilter.Galleries))
query.handleCriterion(ctx, scenePerformerTagsCriterionHandler(qb, sceneFilter.PerformerTags))
query.handleCriterion(ctx, scenePerformerFavoriteCriterionHandler(sceneFilter.PerformerFavorite))
query.handleCriterion(ctx, scenePerformerAgeCriterionHandler(sceneFilter.PerformerAge))
Expand Down Expand Up @@ -1453,6 +1454,15 @@ func sceneMoviesCriterionHandler(qb *SceneStore, movies *models.MultiCriterionIn
return h.handler(movies)
}

func sceneGalleriesCriterionHandler(qb *SceneStore, galleries *models.MultiCriterionInput) criterionHandlerFunc {
addJoinsFunc := func(f *filterBuilder) {
qb.galleriesRepository().join(f, "", "scenes.id")
f.addLeftJoin("galleries", "", "scenes_galleries.gallery_id = galleries.id")
}
h := qb.getMultiCriterionHandlerBuilder(galleryTable, scenesGalleriesTable, "gallery_id", addJoinsFunc)
return h.handler(galleries)
}

func scenePerformerTagsCriterionHandler(qb *SceneStore, tags *models.HierarchicalMultiCriterionInput) criterionHandler {
return &joinedPerformerTagsHandler{
criterion: tags,
Expand Down
2 changes: 2 additions & 0 deletions ui/v2.5/src/models/list-filter/scenes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
import { HasMarkersCriterionOption } from "./criteria/has-markers";
import { SceneIsMissingCriterionOption } from "./criteria/is-missing";
import { MoviesCriterionOption } from "./criteria/movies";
import { GalleriesCriterionOption } from "./criteria/galleries";
import { OrganizedCriterionOption } from "./criteria/organized";
import { PerformersCriterionOption } from "./criteria/performers";
import { ResolutionCriterionOption } from "./criteria/resolution";
Expand Down Expand Up @@ -93,6 +94,7 @@ const criterionOptions = [
PerformerFavoriteCriterionOption,
StudiosCriterionOption,
MoviesCriterionOption,
GalleriesCriterionOption,
createStringCriterionOption("url"),
StashIDCriterionOption,
InteractiveCriterionOption,
Expand Down

0 comments on commit ae6d1a8

Please sign in to comment.