[1036] Improve case studies search filtering with dynamic facet counts and empty-state UX#268
Conversation
WalkthroughThe changes introduce a Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔍 Vulnerabilities of
|
| digest | sha256:79c270c0a6cab87cfa8f902005dbac749e8c78946c2818f6d595944a1c41cfc9 |
| vulnerabilities | |
| platform | linux/amd64 |
| size | 173 MB |
| packages | 972 |
📦 Base Image node:24-alpine
Description
Description
Description
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
Description
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
Description
Description
Description
Description
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
Description
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
Description
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
Description
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
|
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
website/modules/case-studies-page/services/TagCountService.js (2)
95-102: 🧹 Nitpick | 🔵 TrivialMissing JSDoc for
caseStudiesInputparameter.Same issue: the new
caseStudiesInputparameter (line 102) needs documentation.📝 Add missing param documentation
/** * Calculates tag counts for case studies * `@param` {Object} req - ApostropheCMS request object * `@param` {Object} aposModules - ApostropheCMS modules * `@param` {Object} options - Module options + * `@param` {Array} [caseStudiesInput] - Pre-filtered case studies for counting; fetched if omitted * `@returns` {Promise<Object>} Tag counts by type */🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@website/modules/case-studies-page/services/TagCountService.js` around lines 95 - 102, The JSDoc for calculateTagCounts is missing documentation for the new caseStudiesInput parameter; update the function comment block to add a `@param` entry for caseStudiesInput describing its type (e.g., Array or Object), purpose (the pre-fetched list of case studies to compute counts from), and whether it is optional, and ensure the new `@param` aligns with existing parameter style in the calculateTagCounts JSDoc.
45-52: 🧹 Nitpick | 🔵 TrivialMissing JSDoc for
caseStudiesparameter.The new
caseStudiesparameter (line 52) is not documented in the JSDoc block. Add@param {Array} [caseStudies]to describe the optional pre-fetched input.📝 Add missing param documentation
/** * Fetches case studies and tags data from the database * `@param` {Object} req - ApostropheCMS request object * `@param` {Object} aposModules - ApostropheCMS modules * `@param` {Object} options - Module options + * `@param` {Array} [caseStudies] - Pre-fetched case studies; if provided, skips DB fetch * `@returns` {Promise<Array>} Promise resolving to [caseStudies, casesTags, businessPartners] arrays */🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@website/modules/case-studies-page/services/TagCountService.js` around lines 45 - 52, The JSDoc for fetchCaseStudiesAndTags is missing documentation for the new optional caseStudies parameter; update the comment block for static async fetchCaseStudiesAndTags(req, aposModules, options, caseStudies) to include a `@param` {Array} [caseStudies] description (e.g., "Optional pre-fetched array of case study objects to use instead of querying the DB") so the parameter and its optional nature are clearly documented.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@website/modules/case-studies-page/index.js`:
- Around line 70-88: Consolidate the duplicated logic in buildTagCountQuery and
buildIndexQuery by extracting the shared steps (cloning req.query, obtaining
searchTerm via SearchService.getSearchTerm, deleting specific query keys,
calling self.pieces.find(req, {}).applyBuildersSafely(queryParams), invoking
self.filterByIndexPage(query, req.data.page), and attaching the
SearchService.buildSearchCondition using req.data.searchRelationships) into a
new helper (e.g., buildBaseQuery or buildQueryWithOptions) that accepts options
to control deletions (whether to delete page) and pagination behavior (whether
to call .perPage()); then update buildTagCountQuery and buildIndexQuery to call
this helper and apply the remaining specific behavior (.perPage() usage or
omission) while preserving use of applyBuildersSafely, filterByIndexPage,
SearchService.getSearchTerm, and SearchService.buildSearchCondition.
---
Outside diff comments:
In `@website/modules/case-studies-page/services/TagCountService.js`:
- Around line 95-102: The JSDoc for calculateTagCounts is missing documentation
for the new caseStudiesInput parameter; update the function comment block to add
a `@param` entry for caseStudiesInput describing its type (e.g., Array or Object),
purpose (the pre-fetched list of case studies to compute counts from), and
whether it is optional, and ensure the new `@param` aligns with existing parameter
style in the calculateTagCounts JSDoc.
- Around line 45-52: The JSDoc for fetchCaseStudiesAndTags is missing
documentation for the new optional caseStudies parameter; update the comment
block for static async fetchCaseStudiesAndTags(req, aposModules, options,
caseStudies) to include a `@param` {Array} [caseStudies] description (e.g.,
"Optional pre-fetched array of case study objects to use instead of querying the
DB") so the parameter and its optional nature are clearly documented.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: b6a56846-3058-40cf-82c6-918e30a2fe5c
📒 Files selected for processing (2)
website/modules/case-studies-page/index.jswebsite/modules/case-studies-page/services/TagCountService.js
|
@IhorMasechko can you please fix whatever is making #268 (comment) to surround @-names in backticks, so I don't get mentioned on every single PR? |
Summary
Why
Test Plan
/casesand apply search (e.g.Apostrophe) — verify sidebar counts update to match narrowed results.Added dynamic facet count calculation for case studies search filtering. Introduced a new
buildTagCountQueryhelper to pre-filter case studies based on active search and filters, then pass these filtered results toTagCountService.calculateTagCounts. This ensures sidebar counts accurately reflect the narrowed result set rather than static global values, significantly improving filtering accuracy and UX.