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

Added various missing filters to performer page #438

Merged
merged 3 commits into from
Apr 8, 2020
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 @@ -48,6 +48,8 @@ input PerformerFilterType {
aliases: StringCriterionInput
"""Filter by gender"""
gender: GenderCriterionInput
"""Filter to only include performers missing this property"""
is_missing: String
}

input SceneMarkerFilterType {
Expand Down
9 changes: 9 additions & 0 deletions pkg/models/querybuilder_performer.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,15 @@ func (qb *PerformerQueryBuilder) Query(performerFilter *PerformerFilterType, fin
query.addArg(gender.Value.String())
}

if isMissingFilter := performerFilter.IsMissing; isMissingFilter != nil && *isMissingFilter != "" {
switch *isMissingFilter {
case "scenes":
query.addWhere("scenes_join.scene_id IS NULL")
default:
query.addWhere("performers." + *isMissingFilter + " IS NULL")
Anon247 marked this conversation as resolved.
Show resolved Hide resolved
}
}

handleStringCriterion(tableName+".ethnicity", performerFilter.Ethnicity, &query)
handleStringCriterion(tableName+".country", performerFilter.Country, &query)
handleStringCriterion(tableName+".eye_color", performerFilter.EyeColor, &query)
Expand Down
7 changes: 5 additions & 2 deletions ui/v2.5/src/models/list-filter/criteria/criterion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export type CriterionType =
| "duration"
| "favorite"
| "hasMarkers"
| "isMissing"
| "sceneIsMissing"
| "performerIsMissing"
| "tags"
| "sceneTags"
| "performers"
Expand Down Expand Up @@ -52,7 +53,9 @@ export abstract class Criterion {
return "Favorite";
case "hasMarkers":
return "Has Markers";
case "isMissing":
case "sceneIsMissing":
return "Is Missing";
case "performerIsMissing":
return "Is Missing";
case "tags":
return "Tags";
Expand Down
43 changes: 36 additions & 7 deletions ui/v2.5/src/models/list-filter/criteria/is-missing.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { CriterionModifier } from "src/core/generated-graphql";
import { Criterion, CriterionType, ICriterionOption } from "./criterion";

export class IsMissingCriterion extends Criterion {
public type: CriterionType = "isMissing";
export abstract class IsMissingCriterion extends Criterion {
public parameterName: string = "is_missing";
public modifier = CriterionModifier.Equals;
public modifierOptions = [];
public modifier = CriterionModifier.Equals;
public value: string = "";
}

export class SceneIsMissingCriterion extends IsMissingCriterion {
public type: CriterionType = "sceneIsMissing";
public options: string[] = [
"title",
"url",
Expand All @@ -15,10 +19,35 @@ export class IsMissingCriterion extends Criterion {
"movie",
"performers",
];
public value: string = "";
}

export class IsMissingCriterionOption implements ICriterionOption {
public label: string = Criterion.getLabel("isMissing");
public value: CriterionType = "isMissing";
export class SceneIsMissingCriterionOption implements ICriterionOption {
public label: string = Criterion.getLabel("sceneIsMissing");
public value: CriterionType = "sceneIsMissing";
}

export class PerformerIsMissingCriterion extends IsMissingCriterion {
public type: CriterionType = "performerIsMissing";
public options: string[] = [
"url",
"twitter",
"instagram",
"ethnicity",
"country",
"eye_color",
"height",
"measurements",
"fake_tits",
"career_length",
"tattoos",
"piercings",
"aliases",
"gender",
"scenes"
];
}

export class PerformerIsMissingCriterionOption implements ICriterionOption {
public label: string = Criterion.getLabel("performerIsMissing");
public value: CriterionType = "performerIsMissing";
}
9 changes: 5 additions & 4 deletions ui/v2.5/src/models/list-filter/criteria/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from "./criterion";
import { FavoriteCriterion } from "./favorite";
import { HasMarkersCriterion } from "./has-markers";
import { IsMissingCriterion } from "./is-missing";
import {PerformerIsMissingCriterion, SceneIsMissingCriterion} from "./is-missing";
import { NoneCriterion } from "./none";
import { PerformersCriterion } from "./performers";
import { RatingCriterion } from "./rating";
Expand All @@ -35,8 +35,10 @@ export function makeCriteria(type: CriterionType = "none") {
return new FavoriteCriterion();
case "hasMarkers":
return new HasMarkersCriterion();
case "isMissing":
return new IsMissingCriterion();
case "sceneIsMissing":
return new SceneIsMissingCriterion();
case "performerIsMissing":
return new PerformerIsMissingCriterion();
case "tags":
return new TagsCriterion("tags");
case "sceneTags":
Expand All @@ -47,7 +49,6 @@ export function makeCriteria(type: CriterionType = "none") {
return new StudiosCriterion();
case "movies":
return new MoviesCriterion();

case "birth_year":
return new NumberCriterion(type, type);
case "age": {
Expand Down
16 changes: 8 additions & 8 deletions ui/v2.5/src/models/list-filter/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ import {
} from "./criteria/has-markers";
import {
IsMissingCriterion,
IsMissingCriterionOption,
PerformerIsMissingCriterionOption,
SceneIsMissingCriterionOption
} from "./criteria/is-missing";
import { NoneCriterionOption } from "./criteria/none";
import {
Expand Down Expand Up @@ -115,7 +116,7 @@ export class ListFilterModel {
new ResolutionCriterionOption(),
ListFilterModel.createCriterionOption("duration"),
new HasMarkersCriterionOption(),
new IsMissingCriterionOption(),
new SceneIsMissingCriterionOption(),
new TagsCriterionOption(),
new PerformersCriterionOption(),
new StudiosCriterionOption(),
Expand Down Expand Up @@ -145,13 +146,10 @@ export class ListFilterModel {
new NoneCriterionOption(),
new FavoriteCriterionOption(),
new GenderCriterionOption(),
new PerformerIsMissingCriterionOption(),
...numberCriteria.concat(stringCriteria).map(c => ListFilterModel.createCriterionOption(c))
];

this.criterionOptions = this.criterionOptions.concat(
numberCriteria.concat(stringCriteria).map((c) => {
return ListFilterModel.createCriterionOption(c);
})
);
break;
}
case FilterMode.Studios:
Expand Down Expand Up @@ -381,7 +379,7 @@ export class ListFilterModel {
case "hasMarkers":
result.has_markers = (criterion as HasMarkersCriterion).value;
break;
case "isMissing":
case "sceneIsMissing":
result.is_missing = (criterion as IsMissingCriterion).value;
break;
case "tags": {
Expand Down Expand Up @@ -513,6 +511,8 @@ export class ListFilterModel {
};
break;
}
case "performerIsMissing":
result.is_missing = (criterion as IsMissingCriterion).value;
// no default
}
});
Expand Down