fix(catalog): also drop nav-crumb junk on read (self-heal persisted rows)
The parser filter only stops NEW junk from being persisted; vehicles whose trees were already fetched still had "Portal"/eu.nissan.biz rows in the DB, and persistAndBuildLegacyTree/buildCategoryTreeFromDb build from those rows. Filter dbCategories through isNavCrumbLink before buildTree in both, so the response self-heals for previously-persisted junk without a DB migration. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -666,7 +666,9 @@ export class CatalogService {
|
||||
and(eq(categories.catalogVehicleId, catalogVehicleId), sql`${categories.parentId} IS NULL`),
|
||||
);
|
||||
if (dbCategories.length === 0) return [];
|
||||
const tree = this.buildTree(dbCategories);
|
||||
// Same nav-crumb read filter as persistAndBuildLegacyTree (self-heals
|
||||
// previously-persisted Hyundai "Portal" / Nissan eu.nissan.biz junk rows).
|
||||
const tree = this.buildTree(dbCategories.filter((c) => !this.isNavCrumbLink(c.linkPath)));
|
||||
await this.redis.setJson(cacheKey, tree, 3600); // 1h cache for DB fallback
|
||||
return tree;
|
||||
}
|
||||
@@ -1305,7 +1307,10 @@ export class CatalogService {
|
||||
.where(eq(catalogVehicles.id, catalogVehicleId));
|
||||
}
|
||||
|
||||
const tree = this.buildTree(dbCategories);
|
||||
// Filter on read too — drops nav-crumb junk that was persisted before this
|
||||
// fix (e.g. existing Hyundai "Portal" / Nissan eu.nissan.biz rows), so the
|
||||
// response self-heals without a DB migration.
|
||||
const tree = this.buildTree(dbCategories.filter((c) => !this.isNavCrumbLink(c.linkPath)));
|
||||
await this.redis.setJson(cacheKey, tree, 7200);
|
||||
return tree;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user