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

Markers scene filter #5097

Merged
merged 2 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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/schema/types/filters.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ input SceneMarkerFilterType {
scene_tags: HierarchicalMultiCriterionInput
"Filter to only include scene markers with these performers"
performers: MultiCriterionInput
"Filter to only include scene markers from these scenes"
scenes: MultiCriterionInput
"Filter by creation time"
created_at: TimestampCriterionInput
"Filter by last update time"
Expand Down
2 changes: 2 additions & 0 deletions pkg/models/scene_marker.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ type SceneMarkerFilterType struct {
SceneTags *HierarchicalMultiCriterionInput `json:"scene_tags"`
// Filter to only include scene markers with these performers
Performers *MultiCriterionInput `json:"performers"`
// Filter to only include scene markers from these scenes
Scenes *MultiCriterionInput `json:"scenes"`
// Filter by created at
CreatedAt *TimestampCriterionInput `json:"created_at"`
// Filter by updated at
Expand Down
16 changes: 16 additions & 0 deletions pkg/sqlite/scene_marker_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func (qb *sceneMarkerFilterHandler) criterionHandler() criterionHandler {
qb.tagsCriterionHandler(sceneMarkerFilter.Tags),
qb.sceneTagsCriterionHandler(sceneMarkerFilter.SceneTags),
qb.performersCriterionHandler(sceneMarkerFilter.Performers),
qb.scenesCriterionHandler(sceneMarkerFilter.Scenes),
&timestampCriterionHandler{sceneMarkerFilter.CreatedAt, "scene_markers.created_at", nil},
&timestampCriterionHandler{sceneMarkerFilter.UpdatedAt, "scene_markers.updated_at", nil},
&dateCriterionHandler{sceneMarkerFilter.SceneDate, "scenes.date", qb.joinScenes},
Expand Down Expand Up @@ -187,3 +188,18 @@ func (qb *sceneMarkerFilterHandler) performersCriterionHandler(performers *model
handler(ctx, f)
}
}

func (qb *sceneMarkerFilterHandler) scenesCriterionHandler(scenes *models.MultiCriterionInput) criterionHandlerFunc {
addJoinsFunc := func(f *filterBuilder) {
f.addLeftJoin(sceneTable, "markers_scenes", "markers_scenes.id = scene_markers.scene_id")
}
h := multiCriterionHandlerBuilder{
primaryTable: sceneMarkerTable,
foreignTable: "markers_scenes",
joinTable: "",
primaryFK: sceneIDColumn,
foreignFK: sceneIDColumn,
addJoinsFunc: addJoinsFunc,
}
return h.handler(scenes)
}
8 changes: 6 additions & 2 deletions ui/v2.5/src/components/List/Filters/LabeledIdFilter.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from "react";
import { Form } from "react-bootstrap";
import { FilterSelect, SelectObject } from "src/components/Shared/Select";
import { objectTitle } from "src/core/files";
import { galleryTitle } from "src/core/galleries";
import { Criterion } from "src/models/list-filter/criteria/criterion";
import { ILabeledId } from "src/models/list-filter/types";
Expand Down Expand Up @@ -31,8 +32,11 @@ export const LabeledIdFilter: React.FC<ILabeledIdFilterProps> = ({
}

function getLabel(i: SelectObject) {
if (inputType === "galleries") {
return galleryTitle(i);
switch (inputType) {
case "galleries":
return galleryTitle(i);
case "scenes":
return objectTitle(i);
}

return i.name ?? i.title ?? "";
Expand Down
29 changes: 28 additions & 1 deletion ui/v2.5/src/models/list-filter/criteria/scenes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { ILabeledIdCriterion, ILabeledIdCriterionOption } from "./criterion";
import {
CriterionOption,
ILabeledIdCriterion,
ILabeledIdCriterionOption,
} from "./criterion";
import { CriterionModifier } from "src/core/generated-graphql";

const inputType = "scenes";

Expand All @@ -15,3 +20,25 @@ export class ScenesCriterion extends ILabeledIdCriterion {
super(ScenesCriterionOption);
}
}

const modifierOptions = [
CriterionModifier.Includes,
CriterionModifier.Excludes,
];

const defaultModifier = CriterionModifier.Includes;

export const MarkersScenesCriterionOption = new CriterionOption({
messageID: "scenes",
type: "scenes",
modifierOptions,
defaultModifier,
inputType,
makeCriterion: () => new MarkersScenesCriterion(),
});

export class MarkersScenesCriterion extends ILabeledIdCriterion {
constructor() {
super(MarkersScenesCriterionOption);
}
}
2 changes: 2 additions & 0 deletions ui/v2.5/src/models/list-filter/scene-markers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { PerformersCriterionOption } from "./criteria/performers";
import { MarkersScenesCriterionOption } from "./criteria/scenes";
import { SceneTagsCriterionOption, TagsCriterionOption } from "./criteria/tags";
import { ListFilterOptions } from "./filter-options";
import { DisplayMode } from "./types";
Expand All @@ -18,6 +19,7 @@ const sortByOptions = [
const displayModeOptions = [DisplayMode.Wall];
const criterionOptions = [
TagsCriterionOption,
MarkersScenesCriterionOption,
SceneTagsCriterionOption,
PerformersCriterionOption,
createMandatoryTimestampCriterionOption("created_at"),
Expand Down
Loading