fix(trustlab): fix list filters — repeated query params, singular keys, toolkit/playbook date filtering#1493
Merged
Merged
Conversation
normalizeQueryList/singleQueryValue/setSearchParam centralise repeated-param (de)serialisation; buildDateRangeCondition builds UTC date-range where-clauses. Replaces ad-hoc comma-join/split logic that broke on comma-bearing values.
Use page.* pageExtensions instead of bare js/ts/tsx so co-located *.test.js files are not collected as (phantom) API routes.
Location/opportunity filters use exact equals/in (values come from an enumerated dropdown); search now matches title OR location; date filtering via shared buildDateRangeCondition. Fixes comma-bearing values (e.g. "Nairobi, Kenya") being split.
Drop the singular->plural keyMap; year/month/report are singular end to end (filter.type === URL param === API param), matching the CMS filter config.
…om URL APIs now read singular year/month (front-end sent year/month while the API read years/months, so date filtering never applied). Consolidate onto buildDateRangeCondition; serialise repeated params; restore filter results from bookmarked URLs.
Add index:true to title (all four collections) and location (opportunities) to back the list filters/search. Note: triggers an index build on deploy.
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
kelvinkipruto
approved these changes
Jun 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
What & why
Multi-value list filters serialised as comma-joined strings, so any value containing a comma (e.g.
Nairobi, Kenya) was split and corrupted the backend query. This switches to repeated query params, consolidates date-range/query-param logic into shared, tested utilities, and standardises filter params to singular names end to end (filter.type=== URL param === API param), matching the CMS filter config.years→year,months→month,reports→report). Stale bookmarked / multi-select links silently reset — accepted trade-off.year/month, API readyears/months) and now works.equals/in); search now matches title OR location.pageExtensionstightened topage.*so co-located*.test.jsfiles stop being collected as phantom API routes.title(all four) +location(opportunities) — triggers an index build on deploy.Verified
equalsis exact (substring → 0); toolkit/playbookyear=2025→0 vsyear=2026→5 (filter now honoured); repeated multi-value params; title+location search; renamedreportslug filter.Known limitations (out of scope)
title/locationbut not thedate/createdAt/slugfields the range filters scan.Test plan
pnpm jest --filter=trustlab(177 passing)pnpm lint:check/pnpm format:checkpnpm build --filter=trustlabType of change
Screenshots
N/A
Checklist: