[object Object]

← back to Wallco Ai

fix(by-id-image): query all_designs not spoon_all_designs in PG fallback

13587cd66d5014d7ee693f8906b06030fc691d22 · 2026-05-29 07:54:07 -0700 · Steve Abrams

Mac2: spoon_all_designs is a view of all_designs — same rows either way.
Prod: spoon_all_designs is an INDEPENDENT sparse table (~350 rows) while
all_designs holds the historical catalog (5170 drunk-animals alone). The
old query returned 0 rows on prod, so d stayed undefined and the handler
404'd despite the PNG sitting on disk.

Surfaced when the cactus-curator showed 90 PUB-badged drunk-animals
with blank images. Now /designs/img/by-id/9883 -> 200 on prod.

Files touched

Diff

commit 13587cd66d5014d7ee693f8906b06030fc691d22
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Fri May 29 07:54:07 2026 -0700

    fix(by-id-image): query all_designs not spoon_all_designs in PG fallback
    
    Mac2: spoon_all_designs is a view of all_designs — same rows either way.
    Prod: spoon_all_designs is an INDEPENDENT sparse table (~350 rows) while
    all_designs holds the historical catalog (5170 drunk-animals alone). The
    old query returned 0 rows on prod, so d stayed undefined and the handler
    404'd despite the PNG sitting on disk.
    
    Surfaced when the cactus-curator showed 90 PUB-badged drunk-animals
    with blank images. Now /designs/img/by-id/9883 -> 200 on prod.
---
 server.js | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/server.js b/server.js
index fef1157..7ac84c0 100644
--- a/server.js
+++ b/server.js
@@ -2922,7 +2922,15 @@ app.get('/designs/img/by-id/:id', (req, res) => {
   // local_path — otherwise the entire ghost-flagged set 404s.
   if (!d || !d.local_path) {
     try {
-      const raw = psqlQuery(`SELECT row_to_json(t) FROM (SELECT id, image_url, local_path FROM spoon_all_designs WHERE id=${id} LIMIT 1) t;`);
+      // Query all_designs directly (NOT spoon_all_designs). On Mac2 the view
+      // and the base table return the same rows, but on prod spoon_all_designs
+      // is an independent sparse table (~350 rows) while all_designs holds the
+      // historical catalog (5000+ rows for drunk-animals alone). The 2026-05-29
+      // /admin/cactus-curator?category=drunk-animals incident surfaced this —
+      // 90 cards rendered with PUB badges but blank images because the fallback
+      // queried spoon_all_designs, got 0 rows on prod, and 404'd despite the
+      // PNG sitting on disk.
+      const raw = psqlQuery(`SELECT row_to_json(t) FROM (SELECT id, image_url, local_path FROM all_designs WHERE id=${id} LIMIT 1) t;`);
       if (raw && raw.length > 2) {
         const row = JSON.parse(raw);
         if (row && row.local_path) {

← 4781d58 fix(by-id-image): add IMG_DIR + basename(local_path) candida  ·  back to Wallco Ai  ·  feat(mockup-queue): auto-refresh designs.json + hot-reload s ccbd1fb →