fix(pl24): cleaner BMW model — append chassis only, drop redundant line token
Some checks failed
QA Gate (P0/P1) / Test affected app (pull_request) Has been cancelled

"Seri" is "{line} {chassis} [{variant}]" and the trim already implies the line
("520i"→5, "X3 sDrive20i"→X3), so append only the chassis(+variant): "520i G30",
"X3 sDrive20i G01" (was "520i 5 G30" / the redundant "X3 sDrive20i X3 G01").

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-04 23:55:22 +03:00
parent d3ff19ad6a
commit 94faa6cdcd
2 changed files with 10 additions and 6 deletions

View File

@@ -141,10 +141,10 @@ describe("PL24Service.parseVehicleResponse — p5bmw (no prNr; chassis in 'Seri'
},
};
it("folds the chassis/generation ('Seri') into the model so it isn't ambiguous", () => {
it("folds the chassis ('Seri' minus the redundant line token) into the model", () => {
const r = p.parseVehicleResponse("WBAJA3100LCD26756", bmwData as never, "bmw_parts");
expect(r.model).toBe("520i 5 G30");
expect(r.series).toBe("5 G30");
expect(r.model).toBe("520i G30"); // "520i" + chassis "G30" (line "5" dropped — implied by "520i")
expect(r.series).toBe("5 G30"); // series keeps the full "Seri"
});
it("derives year from production date, body from 'Karoseri', engine from 'Motor kodu'", () => {

View File

@@ -1079,10 +1079,14 @@ export class PL24Service {
lookup("model_bilgisi", "model")?.trim() ||
(data.description as string)?.split(" - ")[0]?.trim() ||
"";
const generation = lookup("seri", "model_tanimi");
// "Seri" is "{line} {chassis} [{variant}]" ("5 G30", "X3 G01", "5 E60 MUE"). The trim already
// implies the line ("520i"→5, "X3 sDrive20i"→X3), so drop the leading line token and append
// only the chassis(+variant) → "520i G30", "X3 sDrive20i G01" (avoids a redundant "X3 X3").
const seri = lookup("seri", "model_tanimi");
const chassis = seri ? seri.replace(/^\S+\s+/, "").trim() : null;
const model =
generation && baseModel && !baseModel.toLowerCase().includes(generation.toLowerCase())
? `${baseModel} ${generation}`
chassis && baseModel && !baseModel.toLowerCase().includes(chassis.toLowerCase())
? `${baseModel} ${chassis}`
: baseModel;
return {