fix(pl24): correct p5fiat vinfoBasic label/value extraction
The Fiat vinfoBasic record carries the row under `values` like p5vwag, but the
inner field names are swapped: p5fiat uses values.key=<label>,
values.description=<value> (vwag uses values.description=<label>,
values.value=<value>). The first pass read values.description as the label, so
model fell back to the numeric description code ("319") and year to 0. Detect
the shape via values.key. Live-verified: ZFA Panda→"Panda POP 1.2 8V 69CV 5M E6"
/2014, Grande Punto/2009, 500L/2015. Spec fixture corrected to the real shape.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -999,31 +999,19 @@ export class PL24Service {
|
||||
const segments =
|
||||
(data.segments as Record<
|
||||
string,
|
||||
{
|
||||
records?: Array<{
|
||||
values?: Record<string, string>;
|
||||
key?: string;
|
||||
description?: string;
|
||||
code?: string;
|
||||
}>;
|
||||
}
|
||||
{ records?: Array<{ values?: Record<string, string | undefined> }> }
|
||||
>) || {};
|
||||
const vinfoRecords = segments.vinfoBasic?.records || [];
|
||||
|
||||
const vehicleData: Record<string, string> = {};
|
||||
for (const record of vinfoRecords) {
|
||||
// Two record shapes across P5 backends:
|
||||
// p5vwag etc.: { values: { description: <label>, value: <value> } }
|
||||
const v = record.values;
|
||||
if (!v) continue;
|
||||
// Both shapes carry the row under `values`, but the inner field names differ:
|
||||
// p5vwag etc.: { description: <label>, value: <value> }
|
||||
// p5fiat: { key: <label>, description: <value>, code?: <code> }
|
||||
let label = "";
|
||||
let value = "";
|
||||
if (record.values) {
|
||||
label = record.values.description || "";
|
||||
value = record.values.value || "";
|
||||
} else if (record.key) {
|
||||
label = record.key;
|
||||
value = record.description || "";
|
||||
}
|
||||
const label = (v.key !== undefined ? v.key : v.description) || "";
|
||||
const value = (v.key !== undefined ? v.description : v.value) || "";
|
||||
if (!label) continue;
|
||||
const key = label.toLowerCase().replace(/[\s\/]+/g, "_");
|
||||
if (!(key in vehicleData)) vehicleData[key] = value.replace(/\r?\n/g, " ").trim();
|
||||
|
||||
Reference in New Issue
Block a user