← back to Saloonwallpaper
fix: /api/facets total + counts now reflect filtered list (q, aesthetic, vendor)
05f7a5748a00911582553de489367c8e0da696e5 · 2026-05-25 21:29:51 -0700 · Steve
Files touched
Diff
commit 05f7a5748a00911582553de489367c8e0da696e5
Author: Steve <steve@designerwallcoverings.com>
Date: Mon May 25 21:29:51 2026 -0700
fix: /api/facets total + counts now reflect filtered list (q, aesthetic, vendor)
---
server.js | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/server.js b/server.js
index 0c46d93..ed3e6d3 100644
--- a/server.js
+++ b/server.js
@@ -194,12 +194,20 @@ app.get('/api/sliders', (req, res) => {
});
app.get('/api/facets', (req, res) => {
+ const { q, aesthetic, vendor } = 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);
+ if (vendor && vendor !== 'all') list = list.filter(p => p.vendor === vendor);
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 }));
← 76cd491 wire api-vendor-redact middleware as first app.use (strips v
·
back to Saloonwallpaper
·
rails: wire /api/sliders into horizontal scroll-snap rail se f1e7ec9 →