← back to Bestwallpaperplace
fix: statVendors hero stat always showed 0 — add vendor_count to /api/facets
8b8f83184d8f5dacb8bf69e804d269d7ce9e2808 · 2026-05-30 21:33:44 -0700 · Steve Abrams
api-vendor-redact strips the `vendors` map from /api/facets responses so
Object.keys(d.vendors||{}).length was always 0 in the frontend. Add a safe
numeric `vendor_count` field server-side (count only, no names) and use it
in the facets fetch to display the correct "N Houses" stat in the hero.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Files touched
M public/index.htmlM server.js
Diff
commit 8b8f83184d8f5dacb8bf69e804d269d7ce9e2808
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Sat May 30 21:33:44 2026 -0700
fix: statVendors hero stat always showed 0 — add vendor_count to /api/facets
api-vendor-redact strips the `vendors` map from /api/facets responses so
Object.keys(d.vendors||{}).length was always 0 in the frontend. Add a safe
numeric `vendor_count` field server-side (count only, no names) and use it
in the facets fetch to display the correct "N Houses" stat in the hero.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
---
public/index.html | 2 +-
server.js | 4 +++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/public/index.html b/public/index.html
index 92c17f2..e9eb432 100644
--- a/public/index.html
+++ b/public/index.html
@@ -563,7 +563,7 @@ a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible
// facets
fetch('/api/facets').then(r => r.json()).then(d => {
document.getElementById('statCount').textContent = d.total.toLocaleString();
- document.getElementById('statVendors').textContent = Object.keys(d.vendors || {}).length;
+ document.getElementById('statVendors').textContent = d.vendor_count ?? Object.keys(d.vendors || {}).length;
}).catch(()=>{});
// grid render + infinite scroll
diff --git a/server.js b/server.js
index 732ecc4..254e8dd 100644
--- a/server.js
+++ b/server.js
@@ -165,7 +165,9 @@ app.get('/api/products', (req, res) => {
app.get('/api/facets', (req, res) => {
const vendors = {};
for (const p of PRODUCTS) vendors[p.vendor || 'Unknown'] = (vendors[p.vendor || 'Unknown'] || 0) + 1;
- res.json({ vendors, total: PRODUCTS.length });
+ // vendor_count is safe to expose (a number, not vendor names); the redact
+ // middleware drops the `vendors` map but leaves other keys untouched.
+ res.json({ vendors, vendor_count: Object.keys(vendors).length, total: PRODUCTS.length });
});
app.get('/api/health', (req, res) => res.json({ status: 'ok', count: PRODUCTS.length }));
← 51f3905 feat(fleet): theme1/theme2 query-param-gated toggle on catal
·
back to Bestwallpaperplace
·
scrub residual 3rd-party vendor names from products.json sou 1f926b2 →