Skip to content

feat: support negated text filters and search with "!" prefix - #549

Open
Zufallsgenerat0r wants to merge 1 commit into
CyferShepard:unstablefrom
Zufallsgenerat0r:feat/negate-filters
Open

Zufallsgenerat0r wants to merge 1 commit into
CyferShepard:unstablefrom
Zufallsgenerat0r:feat/negate-filters

Conversation

@Zufallsgenerat0r

Copy link
Copy Markdown

Closes #545

Column filters and the search box only supported include-style substring matching (LIKE '%term%'). A leading ! now inverts the match: !alice excludes that user.

  • parseTextFilter() / buildSearchCondition() in db-helper.js handle the prefix. Only string values are parsed; booleans/numbers (e.g. the documented IsPaused: false) are ignored as before.
  • NOT LIKE is rendered NULL-safe: (col IS NULL OR col NOT LIKE $n), so rows with a NULL Client/DeviceName/IP are kept by an exclusion filter.
  • A bare ! applies no filter (avoids excluding everything while typing).
  • The six inline search LIKE sites in api.js/stats.js use the shared helper, so the search box gets the same behaviour.
  • Fixes a latent aliasing bug in buildFilterList: the CTE copy of a text filter mutated the same object already pushed to query.where, leaving one bound parameter unreferenced.
  • Activity table text columns show a placeholder hint (new en-GB key ACTIVITY_TABLE.FILTER_EXCLUDE_HINT, other locales fall back).

Test plan

  • Activity tab → User filter !alice → alice rows gone, rows with NULL Client/Device still present
  • Filter alice → unchanged include behaviour
  • Type only ! → no filtering applied
  • Search box !breaking → titles without "breaking"
  • Library items search (getLibraryItemsWithStats) !foo
  • Non-English locale → hint falls back to English, no raw key shown

Column filters and the search box on the Activity/History views only
supported include-style substring matching (LIKE '%term%'). A leading
"!" now inverts the match so e.g. "!alice" excludes that user.

- db-helper: parseTextFilter() handles the "!" prefix; buildFilterList
  uses it for filter.value. A bare "!" or empty term applies no filter
  instead of excluding everything while the user is still typing.
- buildWhereClause renders NOT LIKE as
  (col IS NULL OR col NOT LIKE $n) so rows with a NULL column (Client,
  DeviceName, RemoteEndPoint can be NULL) are kept by an exclusion
  filter; plain NOT LIKE would drop them.
- buildSearchCondition() replaces the six inline search LIKE blocks in
  api.js/stats.js so the search box gets the same behaviour.
- Fix latent aliasing bug in buildFilterList: the CTE copy of a text
  filter mutated the same object already pushed to query.where, which
  left one bound parameter unreferenced.
- Activity table text columns show a placeholder hint for the "!"
  syntax (new en-GB key ACTIVITY_TABLE.FILTER_EXCLUDE_HINT).

Closes CyferShepard#545
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant