Skip to content

Commit

Permalink
My fingerprints: Add tag filter and title sorting, and fix trending (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
InfiniteStash authored Jan 24, 2025
1 parent 38b6b13 commit ad500e3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
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

0 comments on commit ad500e3

Please sign in to comment.