feat: QuickGroups shortcut — VIN SSD + vid=0 for fast category fetch
Some checks failed
CI / Lint, Typecheck, Test & Build (push) Has been cancelled
Some checks failed
CI / Lint, Typecheck, Test & Build (push) Has been cancelled
When EMEX DB has no vehicle match (Ford EU, Mercedes etc.), instead of
falling back to full on-demand VIN decode (~8s), use the VIN-decode SSD
directly with QuickGroups.aspx?c={catalog}&vid=0&ssd={vinSsd} (~2-3s).
Tested: Ford Focus CB4 VIN SSD returns 376 categories via QuickGroups.
New step 3.5 in the cascade:
1. pathData → matchByName (DB-only, ~50ms)
2. emexVehicleName → matchByName (DB-only, ~50ms)
3. matchBySsd wizard walk (DB, ~2-3s)
3.5. VIN SSD → QuickGroups shortcut (~2-3s) ← NEW
4. Fallback → full on-demand scrape (~8s)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -290,6 +290,42 @@ export class CategoriesService {
|
||||
}
|
||||
}
|
||||
|
||||
// Step 3.5: VIN SSD → QuickGroups shortcut (~2-3s, skips full VIN decode)
|
||||
if (catalogCode && dbCategories.length === 0) {
|
||||
const ssd = vRawData?.ssd as string | undefined;
|
||||
if (ssd) {
|
||||
try {
|
||||
this.logger.log(`EMEX step 3.5: QuickGroups shortcut (c=${catalogCode}, ssd=${ssd.slice(0, 30)}...)`);
|
||||
const qgCats = await this.emexService.fetchQuickGroupsBySsd(catalogCode, ssd);
|
||||
if (qgCats.length > 0) {
|
||||
const seenNames = new Set<string>();
|
||||
const uniqueCats = qgCats.filter((c) => {
|
||||
if (seenNames.has(c.name)) return false;
|
||||
seenNames.add(c.name);
|
||||
return true;
|
||||
});
|
||||
|
||||
const insertData = uniqueCats.map((c) => ({
|
||||
vehicleId,
|
||||
catalogVehicleId: null as string | null,
|
||||
name: c.name,
|
||||
nameOriginal: c.name,
|
||||
parentId: null as string | null,
|
||||
externalId: c.gid,
|
||||
linkPath: c.url || null,
|
||||
linkWid: null as string | null,
|
||||
source: "emex" as const,
|
||||
}));
|
||||
|
||||
dbCategories = await this.db.insert(categories).values(insertData).onConflictDoNothing().returning();
|
||||
this.logger.log(`Stored ${dbCategories.length} EMEX QuickGroups categories for ${vehicle.vin}`);
|
||||
}
|
||||
} catch (err) {
|
||||
this.logger.warn(`EMEX QuickGroups shortcut failed: ${(err as Error).message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Step 4: Fallback → on-demand EMEX scrape (existing behavior, ~6-13s)
|
||||
if (dbCategories.length === 0) {
|
||||
this.logger.log(`EMEX step 4: on-demand fallback for ${vehicle.vin}`);
|
||||
|
||||
Reference in New Issue
Block a user