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

My fingerprints: Add tag filter and title sorting, and fix trending #911

Merged
merged 1 commit into from
Jan 24, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ import {
SceneSortEnum,
useUnmatchFingerprint,
FingerprintAlgorithm,
CriterionModifier,
} from "src/graphql";
import { usePagination, useQueryParams } from "src/hooks";
import { ensureEnum } from "src/utils";
import { ErrorMessage, Icon } from "src/components/fragments";
import List from "src/components/list/List";
import Modal from "src/components/modal";
import TagFilter from "src/components/tagFilter";
import UserSceneLine from "./UserSceneLine";

const PER_PAGE = 20;
Expand All @@ -29,6 +31,7 @@ interface Props {

const sortOptions = [
{ value: SceneSortEnum.DATE, label: "Release Date" },
{ value: SceneSortEnum.TITLE, label: "Title" },
{ value: SceneSortEnum.TRENDING, label: "Trending" },
{ value: SceneSortEnum.CREATED_AT, label: "Created At" },
{ value: SceneSortEnum.UPDATED_AT, label: "Updated At" },
Expand All @@ -52,6 +55,7 @@ export const UserFingerprintsList: FC<Props> = ({
const [params, setParams] = useQueryParams({
sort: { name: "sort", type: "string", default: SceneSortEnum.DATE },
dir: { name: "dir", type: "string", default: SortDirectionEnum.DESC },
tag: { name: "tag", type: "string" },
});
const sort = ensureEnum(SceneSortEnum, params.sort);
const direction = ensureEnum(SortDirectionEnum, params.dir);
Expand All @@ -64,6 +68,9 @@ export const UserFingerprintsList: FC<Props> = ({
sort,
direction,
...filter,
tags: params.tag
? { value: [params.tag], modifier: CriterionModifier.INCLUDES }
: undefined,
},
submitted: true,
});
Expand All @@ -72,6 +79,7 @@ export const UserFingerprintsList: FC<Props> = ({

const filters = (
<InputGroup className="scene-sort w-auto">
<TagFilter tag={params.tag} onChange={(t) => setParams("tag", t?.id)} />
<Form.Select
className="w-auto"
onChange={(e) => setParams("sort", e.currentTarget.value.toLowerCase())}
Expand Down
2 changes: 1 addition & 1 deletion pkg/sqlx/querybuilder_scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ func (qb *sceneQueryBuilder) buildQuery(filter models.SceneQueryInput, userID uu
FROM scene_fingerprints
WHERE user_id = ?
GROUP BY scene_id
) T ON scenes.id = T.scene_id
) SFP ON scenes.id = SFP.scene_id
`
query.AddArg(userID)
}
Expand Down
Loading