← back to Restorationwallpaper
/api/facets: counts + total reflect filtered list (q + aesthetic), not entire catalog
04071f806cc4b1f5643ea1d55c296bc524d58d5e · 2026-05-25 21:30:33 -0700 · Steve Abrams
Files touched
Diff
commit 04071f806cc4b1f5643ea1d55c296bc524d58d5e
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Mon May 25 21:30:33 2026 -0700
/api/facets: counts + total reflect filtered list (q + aesthetic), not entire catalog
---
server.js | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/server.js b/server.js
index b56155e..43d39e4 100644
--- a/server.js
+++ b/server.js
@@ -197,12 +197,23 @@ app.get('/api/sliders', (req, res) => {
});
app.get('/api/facets', (req, res) => {
+ // Facet counts + total reflect the FILTERED list, not the entire catalog,
+ // so chip counts + the header total update live as the user narrows the set
+ // via search / aesthetic filter. (?vendor= is already stripped upstream by
+ // the api-vendor-redact middleware, so vendor filtering is dormant.)
+ const { q, aesthetic } = req.query;
+ let list = PRODUCTS;
+ if (q) {
+ const needle = String(q).toLowerCase();
+ list = list.filter(p => (p.title || '').toLowerCase().includes(needle) || (p.tags || []).some(t => String(t).toLowerCase().includes(needle)));
+ }
+ if (aesthetic && aesthetic !== 'all') list = list.filter(p => p.aesthetic === aesthetic);
const aesthetics = {}; const vendors = {};
- for (const p of PRODUCTS) {
+ for (const p of list) {
aesthetics[p.aesthetic] = (aesthetics[p.aesthetic] || 0) + 1;
vendors[p.vendor] = (vendors[p.vendor] || 0) + 1;
}
- res.json({ aesthetics, vendors, total: PRODUCTS.length });
+ res.json({ aesthetics, vendors, total: list.length });
});
app.get('/api/health', (req, res) => res.json({ status: 'ok', count: PRODUCTS.length, dropped: DROPPED }));
← e668625 wire api-vendor-redact middleware (strip vendor field + vend
·
back to Restorationwallpaper
·
rails: wire /api/sliders into horizontal scroll-snap rail se 3e1baf6 →