← back to Wallco Ai
PDP: fall back to wallco_rooms table for room_mockups when designs.json snapshot is empty — rooms now appear on every SKU product page durably (survives snapshot rebuilds), file-existence guarded so no broken imgs
a049441517734d1124aaba679a64fb55288292df · 2026-05-29 22:20:43 -0700 · Steve Abrams
Files touched
Diff
commit a049441517734d1124aaba679a64fb55288292df
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Fri May 29 22:20:43 2026 -0700
PDP: fall back to wallco_rooms table for room_mockups when designs.json snapshot is empty — rooms now appear on every SKU product page durably (survives snapshot rebuilds), file-existence guarded so no broken imgs
---
server.js | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/server.js b/server.js
index 225fca9..373a7ab 100644
--- a/server.js
+++ b/server.js
@@ -11544,6 +11544,23 @@ app.get('/design/:id', (req, res) => {
{ id: 'commercial', label: 'Commercial', candidates: ['office','boardroom','retail'] },
{ id: 'hospitality', label: 'Hospitality', candidates: ['hotel_lobby','restaurant','hotel_corridor'] }
];
+ // Durable room source (2026-05-29): design.room_mockups comes from the
+ // designs.json snapshot, which resets to [] after a snapshot rebuild even
+ // when wallco_rooms holds live renders (the room PNGs serve fine, but the PDP
+ // room section was gated on the stale snapshot field — rooms silently vanished
+ // from the customer product page). Fall back to the authoritative wallco_rooms
+ // table, keeping only room_types whose canonical /designs/room PNG exists on
+ // disk so we never render a broken img.
+ if (!(design.room_mockups || []).length) {
+ try {
+ const _rr = psqlQuery(`SELECT COALESCE(json_agg(DISTINCT room_type),'[]') FROM wallco_rooms
+ WHERE design_id=${id} AND removed_at IS NULL`);
+ const _roomsDir = path.join(__dirname, 'data', 'rooms');
+ const _types = JSON.parse(_rr || '[]').filter(rt =>
+ fs.existsSync(path.join(_roomsDir, `design_${id}_${rt}.png`)));
+ if (_types.length) design.room_mockups = _types;
+ } catch { /* PG hiccup — leave the snapshot value as-is */ }
+ }
const haveRooms = new Set(design.room_mockups || []);
const roomCtx = ROOM_CONTEXTS
.map(c => { const room = c.candidates.find(r => haveRooms.has(r)); return room ? { id: c.id, label: c.label, room } : null; })
← 3bcf7db colorways: admin Publish badge on chip + new_design_publishe
·
back to Wallco Ai
·
id-collision resolutions 1..14999 (134 rows): 106 Mac2 re-pu c72fe45 →