fix(catalog): pcat parent groups no longer show empty "0 parça"

parts-catalogs (pcat) catalogs are deep trees, but every pcat node was
stored as an apparent leaf (pcat: linkPath, no children) until drilled.
Opening an intermediate group called parts2, which returns HTTP 400
("The list of parts is empty"); the drill-to-children fallback only fired
on that exact error string, so any other failure (cold JWT capture,
timeout, 5xx) left both parts and children empty → the UI rendered
"0 parça / bulunamadı" on a node whose parts live 1-3 levels deeper.

#1 Persist the groups2 hasSubgroups/hasParts flags on categories
   (new nullable columns, migration 0007) and use them to classify:
   - getCategoryWithParts routes a known parent (hasSubgroups, !hasParts)
     straight to getChildren, never calling parts2.
   - enrichWithSchemaImages treats flagged parents as expandable, flagged
     parts-leaves as leaves, and only falls back to the "any pcat: is a
     leaf" heuristic for pre-migration rows (flags null).

#2 Make discovery resilient: drill to sub-groups whenever the parts fetch
   produces nothing (empty 200 OR a thrown error), not only on HTTP 400.
   Mark a node unavailable only on a definitive HTTP 400 with no
   sub-groups; transient failures are left for a later retry.

Verified live on prod (VW Passat, "Süspansiyon Çarpanlar"): full path is
Süspansiyon Çarpanlar → Süspansiyon → Süspansiyon 1…5 → 74 parts.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-24 01:02:00 +03:00
parent 1b2cfd4a0f
commit aa4d055c77
6 changed files with 5538 additions and 14 deletions

View File

@@ -0,0 +1,2 @@
ALTER TABLE "categories" ADD COLUMN "has_subgroups" boolean;--> statement-breakpoint
ALTER TABLE "categories" ADD COLUMN "has_parts" boolean;

File diff suppressed because it is too large Load Diff

View File

@@ -50,6 +50,13 @@
"when": 1779086009525,
"tag": "0006_chilly_dark_phoenix",
"breakpoints": true
},
{
"idx": 7,
"version": "7",
"when": 1779573406942,
"tag": "0007_natural_red_wolf",
"breakpoints": true
}
]
}