Skip to content

Commit

Permalink
Collection search: allow searching by series title and anidb id (#915)
Browse files Browse the repository at this point in the history
  • Loading branch information
harshithmohan authored May 24, 2024
1 parent 8d01ca6 commit 001974c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/core/types/api/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@ type ExpressionType =
| 'And'
| 'Not'
| 'Or'
| 'AniDBIDsSelector'
| 'AllContains'
| 'AllRegexMatches'
| 'AnyContains'
| 'AnyEquals'
| 'AnyFuzzyMatches'
| 'AnyRegexMatches'
| 'HasUnwatchedEpisodes'
| 'HasWatchedEpisodes'
| 'NameSelector'
| 'NamesSelector'
| 'StringContains'
| 'StringEndsWith'
| 'StringEquals'
Expand Down
20 changes: 17 additions & 3 deletions src/pages/collection/Collection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,28 @@ const getFilter = (
): FilterType => {
let finalCondition: FilterCondition | undefined;
if (query) {
const searchCondition: FilterCondition = {
Type: 'StringFuzzyMatches',
let searchCondition: FilterCondition = {
Type: 'AnyContains',
Left: {
Type: 'NameSelector',
Type: 'NamesSelector',
},
Parameter: query,
};

if (Number.isFinite(toNumber(query))) {
searchCondition = {
Type: 'Or',
Left: searchCondition,
Right: {
Type: 'AnyEquals',
Left: {
Type: 'AniDBIDsSelector',
},
Parameter: query,
},
};
}

if (filterCondition) {
finalCondition = buildFilter([searchCondition, filterCondition]);
} else {
Expand Down

0 comments on commit 001974c

Please sign in to comment.