← back to Museumwallpaper
/api/facets respect q + aesthetic filters so chip counts match filtered grid
daf22e1a1fb8b430d9d86e3ae1824057004de6ba · 2026-05-25 21:20:23 -0700 · Steve
Files touched
Diff
commit daf22e1a1fb8b430d9d86e3ae1824057004de6ba
Author: Steve <steve@designerwallcoverings.com>
Date: Mon May 25 21:20:23 2026 -0700
/api/facets respect q + aesthetic filters so chip counts match filtered grid
---
server.js | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/server.js b/server.js
index cd8ed90..ea35370 100644
--- a/server.js
+++ b/server.js
@@ -210,12 +210,22 @@ app.get('/api/sliders', (req, res) => {
});
app.get('/api/facets', (req, res) => {
+ // Counts MUST reflect the same filters as /api/products so chip labels match
+ // post-filter card counts (q, aesthetic). vendor filter is dropped upstream by
+ // api-vendor-redact middleware.
+ const { q, aesthetic } = req.query;
+ let list = PRODUCTS_NICHE;
+ 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_NICHE) {
+ 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_NICHE.length });
+ res.json({ aesthetics, vendors, total: list.length });
});
app.get('/api/health', (req, res) => res.json({ status: 'ok', count: PRODUCTS_NICHE.length, dropped: DROPPED }));
← 3a31d07 wire api-vendor-redact middleware (strips vendor/vendors fro
·
back to Museumwallpaper
·
homepage: add retrowalls-canonical rail-sections (id=rails + fe8e7aa →