← back to 4square Admin
4square admin: populate fliepaper-bugs matrix from fliepaper_bugs_cells (36 Gucci cells live under category designer-bugs; pull by cell-set, not category, so the no-FLIEPAPER rename stays intact)
4732fba655c991061b9da8d51eaab12dde13e4f9 · 2026-06-02 08:37:14 -0700 · SteveStudio2
Files touched
Diff
commit 4732fba655c991061b9da8d51eaab12dde13e4f9
Author: SteveStudio2 <steve@designerwallcoverings.com>
Date: Tue Jun 2 08:37:14 2026 -0700
4square admin: populate fliepaper-bugs matrix from fliepaper_bugs_cells (36 Gucci cells live under category designer-bugs; pull by cell-set, not category, so the no-FLIEPAPER rename stays intact)
---
server.js | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/server.js b/server.js
index 22b4d60..2c90859 100644
--- a/server.js
+++ b/server.js
@@ -40,7 +40,7 @@ app.use((req, _res, next) => {
app.get('/api/sources', async (_req, res) => {
try {
const [wallcoCats, wallcoTotal, shopifyVendors, shopifyTotal, shopifyByStatus,
- pbTotal, pbCats, vwTotal, vwDecades] = await Promise.all([
+ pbTotal, pbCats, vwTotal, vwDecades, fbCells] = await Promise.all([
pool.query(`SELECT category, COUNT(*)::int AS n FROM spoon_all_designs WHERE category IS NOT NULL GROUP BY category ORDER BY 2 DESC`),
pool.query(`SELECT COUNT(*)::int AS n FROM spoon_all_designs`),
pool.query(`SELECT vendor, COUNT(*)::int AS n FROM shopify_products WHERE vendor IS NOT NULL GROUP BY vendor ORDER BY 2 DESC LIMIT 30`),
@@ -50,13 +50,19 @@ app.get('/api/sources', async (_req, res) => {
safe(poolPB, `SELECT category, COUNT(*)::int AS n FROM patterns WHERE category IS NOT NULL GROUP BY category ORDER BY 2 DESC LIMIT 20`),
safe(poolVW, `SELECT COUNT(*)::int AS n FROM products`),
safe(poolVW, `SELECT era_decade, COUNT(*)::int AS n FROM products WHERE era_decade IS NOT NULL GROUP BY era_decade ORDER BY 1`),
+ safe(pool, `SELECT COUNT(*)::int AS n FROM fliepaper_bugs_cells WHERE design_id IS NOT NULL`),
]);
const sources = [
{
id: 'wallco', label: 'wallco.ai', kind: 'wallco', total: wallcoTotal.rows[0].n,
children: [
{ id: 'wallco:all', label: 'all designs', n: wallcoTotal.rows[0].n },
- ...wallcoCats.rows.map(r => ({ id: `wallco:${r.category}`, label: r.category, n: r.n, special: r.category === 'fliepaper-bugs' ? 'matrix' : null }))
+ // Bugs matrix (6 patterns × 6 Gucci colorways = 36 cells). The cells live in
+ // all_designs under category 'designer-bugs' (renamed off 'fliepaper-bugs' for the
+ // no-FLIEPAPER rule); fliepaper_bugs_cells is the authoritative cell set. Internal
+ // source id keeps the scaffold name (exempt) — never rendered customer-facing.
+ { id: 'wallco:fliepaper-bugs', label: 'bugs matrix (Gucci)', n: (fbCells.rows && fbCells.rows[0]?.n) || 0, special: 'matrix' },
+ ...wallcoCats.rows.map(r => ({ id: `wallco:${r.category}`, label: r.category, n: r.n }))
],
},
{
@@ -142,7 +148,10 @@ app.get('/api/products', async (req, res) => {
const orderBy = sortClauseWallco(sort);
const params = [];
let where = '1=1';
- if (cat !== 'all') { params.push(cat); where = `category = $${params.length}`; }
+ if (cat === 'fliepaper-bugs') {
+ // 36 matrix cells (authoritative set), regardless of their stored category.
+ where = `id IN (SELECT design_id FROM fliepaper_bugs_cells WHERE design_id IS NOT NULL)`;
+ } else if (cat !== 'all') { params.push(cat); where = `category = $${params.length}`; }
if (q) {
params.push(`%${q}%`);
where += ` AND (dig_number ILIKE $${params.length} OR category ILIKE $${params.length} OR tags::text ILIKE $${params.length})`;
@@ -443,7 +452,7 @@ app.post('/api/bulk/recolor', async (req, res) => {
const target = String(req.body?.target_color || '').trim();
const cw = SPEC.palette.find(c => c.slug === target);
if (!cw) return res.status(400).json({ ok:false, error:`target_color must be one of ${SPEC.palette.map(c=>c.slug).join(',')}` });
- const { rows } = await pool.query(`SELECT id, tags FROM spoon_all_designs WHERE id=ANY($1) AND category='fliepaper-bugs'`, [ids]);
+ const { rows } = await pool.query(`SELECT id, tags FROM spoon_all_designs WHERE id=ANY($1) AND id IN (SELECT design_id FROM fliepaper_bugs_cells)`, [ids]);
const jobs = [];
for (const r of rows) {
const t = (r.tags || []).join(' ');
← 6ffa88e 4square admin: fall back to a populated source when the save
·
back to 4square Admin
·
bulk endpoints: try/catch so settlement-trigger RAISE return 8e74e15 →