chore(debug): TEMP map de Ford variant-tree drill structure + route ford to de

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-05 16:57:13 +03:00
parent 678a33a57a
commit 44284d5f82

View File

@@ -49,11 +49,15 @@ export interface P4BrandHooks {
// Brands whose parts are licensed only on the de (account 2) PL24 subscription —
// the tr account serves a NOT_LOGGED_IN_DEMO page for these. All P4 fetches for
// these services are routed to de (see fetchP4Page + resolveAccount).
const HYUNDAI_KIA_NISSAN_DE = new Set(["hyundai_parts", "kia_parts", "nissan_parts"]);
// Tested on de but NOT helped: Ford (de gives a real variant tree but the current
// drill logic can't reach parts through Ford's engine/transmission variant nodes —
// needs dedicated Ford variant-drill work); Polestar (de returns 0 categories — data
// gap). Fiat stays on de via resolveAccount but its model-list needs launchCatalog.do.
const HYUNDAI_KIA_NISSAN_DE = new Set([
"hyundai_parts",
"kia_parts",
"nissan_parts",
"fordp_parts",
"fordt_parts",
]);
// Polestar tested on de → 0 categories (data gap). Fiat stays on de via
// resolveAccount but its model-list needs launchCatalog.do.
@Injectable()
export class PL24FordLegacyService {
@@ -1798,6 +1802,30 @@ export class PL24FordLegacyService {
`Ford: ${groups.length} groups for ${serviceName}/${familyId} catCode=${catCode ?? "none"} arch=${arch}`,
);
// TEMP DEBUG: map the de Ford variant-tree → drill structure.
if (arch === "LEGACY_FORD" && groups.length > 0) {
this.logger.warn(
`FORD-MAP nodes: ${JSON.stringify(groups.slice(0, 14).map((g) => ({ n: g.nameTr?.slice(0, 28), lp: g.linkPath?.slice(0, 90) })))}`,
);
// drill the first node and dump what comes back
const first = groups[0];
if (first?.linkPath) {
const ch = await this.fetchP4Page(first.linkPath, serviceName, false);
if (ch) {
const rows: string[] = [];
for (const seg of ch.split(/<tr\s/)) {
if (!seg.includes("tc-data-row")) continue;
const m = seg.match(/\burl="([^"]+)"/) || seg.match(/\bjsonUrl="([^"]+)"/i);
const cap = seg.match(/\bcaption="([^"]+)"/)?.[1]?.slice(0, 24);
rows.push(`${cap}::${(m?.[1] || "").slice(0, 50)}`);
}
this.logger.warn(
`FORD-MAP drill "${first.nameTr?.slice(0, 24)}": len=${ch.length} title="${ch.match(/<title>([^<]*)<\/title>/i)?.[1]}" rows=${rows.length} ${JSON.stringify(rows.slice(0, 8))}`,
);
}
}
}
if (groups.length > 0) {
await this.redis.setJson(cacheKey, groups, 7200);
}