← back to Wallco Ai
Add colorway sub-category room-mockup driver (1395 living_room composites generated, TAG-collision-safe)
e70294dc77b15553638ee3bf91e837e5a36e7790 · 2026-05-30 09:49:31 -0700 · Steve
Files touched
A scripts/cw-rooms-driver.sh
Diff
commit e70294dc77b15553638ee3bf91e837e5a36e7790
Author: Steve <steve@designerwallcoverings.com>
Date: Sat May 30 09:49:31 2026 -0700
Add colorway sub-category room-mockup driver (1395 living_room composites generated, TAG-collision-safe)
---
scripts/cw-rooms-driver.sh | 68 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 68 insertions(+)
diff --git a/scripts/cw-rooms-driver.sh b/scripts/cw-rooms-driver.sh
new file mode 100755
index 0000000..abae6eb
--- /dev/null
+++ b/scripts/cw-rooms-driver.sh
@@ -0,0 +1,68 @@
+#!/usr/bin/env bash
+# Colorway sub-category room-mockup generator (Mac2 local only — no prod rsync per DTD verdict B).
+# Reads /tmp/cw-cats.txt (one category per line), generates PIL living_room composites,
+# inserts wallco_rooms rows, reports per-cohort.
+set -uo pipefail
+cd /Users/stevestudio2/Projects/wallco-ai
+OUT=public/uploads/rooms
+mkdir -p "$OUT"
+PG="dw_unified"
+CATS=/tmp/cw-cats.txt
+LOG=/tmp/cw-rooms-run.log
+: > "$LOG"
+log(){ echo "$(date '+%H:%M:%S') $*" | tee -a "$LOG"; }
+
+# ---- 1. Build master list of missing ids across all cohorts ----
+: > /tmp/cw-all-ids.txt
+i=0
+while IFS= read -r CAT; do
+ [ -z "$CAT" ] && continue
+ i=$((i+1))
+ CAT_ESC=$(printf '%s' "$CAT" | sed "s/'/''/g")
+ psql "$PG" -At -q -c "SELECT id FROM all_designs WHERE category='$CAT_ESC' AND is_published=TRUE AND local_path IS NOT NULL AND NOT EXISTS (SELECT 1 FROM wallco_rooms r WHERE r.design_id=all_designs.id AND r.image_path IS NOT NULL) ORDER BY id;" > "/tmp/cwc-${i}-ids.txt"
+ cat "/tmp/cwc-${i}-ids.txt" >> /tmp/cw-all-ids.txt
+done < "$CATS"
+sort -u /tmp/cw-all-ids.txt -o /tmp/cw-all-ids.txt
+TOTAL=$(wc -l < /tmp/cw-all-ids.txt | tr -d ' ')
+log "PIL pass starting: $TOTAL designs across $i cohorts"
+
+# ---- 2. Parallel PIL composite (8 workers) ----
+# Each invocation processes one id; script skips if output already exists.
+cat /tmp/cw-all-ids.txt | xargs -P 8 -n 25 python3 scripts/pil-room-composite.py --out "$OUT" >> "$LOG" 2>&1
+PNGCOUNT=$(ls "$OUT"/design_*_living_room.png 2>/dev/null | wc -l | tr -d ' ')
+log "PIL pass done. living_room PNGs now on disk: $PNGCOUNT"
+
+# ---- 3. Per-cohort SQL insert + report ----
+GRAND=0
+i=0
+while IFS= read -r CAT; do
+ [ -z "$CAT" ] && continue
+ i=$((i+1))
+ IDS="/tmp/cwc-${i}-ids.txt"
+ [ -s "$IDS" ] || { log "[$i] $CAT — 0 ids, skip"; continue; }
+ # which of this cohort's ids actually produced a PNG
+ : > "/tmp/cwc-${i}-final.txt"
+ while IFS= read -r id; do
+ [ -z "$id" ] && continue
+ [ -f "$OUT/design_${id}_living_room.png" ] && echo "$id" >> "/tmp/cwc-${i}-final.txt"
+ done < "$IDS"
+ # build + run insert SQL
+ python3 - "$i" <<'PY' > "/tmp/cwc-${i}-rooms.sql"
+import sys
+i=sys.argv[1]
+ids=[l.strip() for l in open(f'/tmp/cwc-{i}-final.txt') if l.strip()]
+print('BEGIN;')
+for id in ids:
+ fn=f'design_{id}_living_room.png'
+ print(f"INSERT INTO wallco_rooms (design_id, room_type, filename, image_path) SELECT {id}, 'living_room', '{fn}', '/uploads/rooms/{fn}' WHERE NOT EXISTS (SELECT 1 FROM wallco_rooms WHERE design_id={id} AND filename='{fn}');")
+print('COMMIT;')
+PY
+ BEFORE=$(psql "$PG" -At -q -c "SELECT COUNT(*) FROM wallco_rooms WHERE room_type='living_room';")
+ psql "$PG" -q < "/tmp/cwc-${i}-rooms.sql" >> "$LOG" 2>&1
+ AFTER=$(psql "$PG" -At -q -c "SELECT COUNT(*) FROM wallco_rooms WHERE room_type='living_room';")
+ INS=$((AFTER-BEFORE))
+ GRAND=$((GRAND+INS))
+ FINAL=$(wc -l < "/tmp/cwc-${i}-final.txt" | tr -d ' ')
+ log "[$i] $CAT — png:$FINAL inserted:$INS"
+done < "$CATS"
+log "DONE. Total new wallco_rooms inserts: $GRAND"
← 044da51 scripts/security-monitor.sh — 10-min cron detector for UID-0
·
back to Wallco Ai
·
scripts/pil-mural-composite.py: FREE local single-panel mura a54ea58 →