From da6bd071eec72fdfa39eae1b35cfbe651c097414 Mon Sep 17 00:00:00 2001 From: josh Date: Sun, 19 Apr 2026 18:51:56 -0400 Subject: [PATCH] fix: remove lingering FM references from insights services tx.fm.count calls + fmsImplicating fields were missed in the main FM removal pass. Drops the field from Category/Manufacturer/PartModel insights types, services, tests, and detail-page stat cards. Co-Authored-By: Claude Opus 4.7 --- apps/api/src/services/categories.test.ts | 10 ++-------- apps/api/src/services/categories.ts | 5 ----- apps/api/src/services/manufacturers.test.ts | 10 ++-------- apps/api/src/services/manufacturers.ts | 3 --- apps/api/src/services/part-models.test.ts | 13 +------------ apps/api/src/services/part-models.ts | 4 +--- apps/web/src/pages/CategoryDetail.tsx | 8 ++------ apps/web/src/pages/ManufacturerDetail.tsx | 8 ++------ apps/web/src/pages/PartModelDetail.tsx | 8 ++------ packages/shared/src/category-insights.ts | 1 - packages/shared/src/manufacturer-insights.ts | 1 - packages/shared/src/part-model-insights.ts | 1 - 12 files changed, 12 insertions(+), 60 deletions(-) diff --git a/apps/api/src/services/categories.test.ts b/apps/api/src/services/categories.test.ts index c0cda32..2bc5481 100644 --- a/apps/api/src/services/categories.test.ts +++ b/apps/api/src/services/categories.test.ts @@ -17,7 +17,6 @@ interface FakeArgs { }; repairCount: number; distinctFailedBrokenPartIds: string[]; - fmCount: number; modelStateGroups: { partModelId: string; state: string; count: number }[]; allModels: { id: string; @@ -65,9 +64,6 @@ function makeTx(args: FakeArgs): Tx { return args.repairsWithModel; }, }, - fm: { - count: async () => args.fmCount, - }, }; return tx as unknown as Tx; } @@ -79,7 +75,6 @@ const empty: FakeArgs = { priceAgg: { sum: null, avg: null, min: null, max: null, count: 0 }, repairCount: 0, distinctFailedBrokenPartIds: [], - fmCount: 0, modelStateGroups: [], allModels: [], eolModels: [], @@ -124,15 +119,14 @@ describe('categories.getInsights', () => { }); }); - it('counts repairs, distinct failed parts, and FMs implicating the category', async () => { + it('counts repairs and distinct failed parts', async () => { const tx = makeTx({ ...empty, repairCount: 5, distinctFailedBrokenPartIds: ['p1', 'p2', 'p3'], - fmCount: 4, }); const r = await getInsights(tx, 'cat'); - expect(r!.failures).toEqual({ repairs: 5, distinctFailedParts: 3, fmsImplicating: 4 }); + expect(r!.failures).toEqual({ repairs: 5, distinctFailedParts: 3 }); }); it('derives topModelsByUnits from modelStateGroups, sorted desc, truncated to 8', async () => { diff --git a/apps/api/src/services/categories.ts b/apps/api/src/services/categories.ts index 5aa6b50..4527b9d 100644 --- a/apps/api/src/services/categories.ts +++ b/apps/api/src/services/categories.ts @@ -28,7 +28,6 @@ export async function getInsights(tx: Tx, id: string): Promise args.fmCount, - }, }; return tx as unknown as Tx; } @@ -85,7 +81,6 @@ const empty: FakeArgs = { priceAgg: { sum: null, avg: null, min: null, max: null, count: 0 }, repairCount: 0, distinctFailedBrokenPartIds: [], - fmCount: 0, modelStateGroups: [], allModels: [], eolModels: [], @@ -130,15 +125,14 @@ describe('manufacturers.getInsights', () => { }); }); - it('counts repairs, distinct failed parts, and FMs implicating the manufacturer', async () => { + it('counts repairs and distinct failed parts', async () => { const tx = makeTx({ ...empty, repairCount: 5, distinctFailedBrokenPartIds: ['p1', 'p2', 'p3'], - fmCount: 4, }); const r = await getInsights(tx, 'mfr'); - expect(r!.failures).toEqual({ repairs: 5, distinctFailedParts: 3, fmsImplicating: 4 }); + expect(r!.failures).toEqual({ repairs: 5, distinctFailedParts: 3 }); }); it('derives topModelsByUnits from modelStateGroups, sorted desc, truncated to 8', async () => { diff --git a/apps/api/src/services/manufacturers.ts b/apps/api/src/services/manufacturers.ts index 4987ebf..41716bf 100644 --- a/apps/api/src/services/manufacturers.ts +++ b/apps/api/src/services/manufacturers.ts @@ -27,7 +27,6 @@ export async function getInsights(tx: Tx, id: string): Promise args.distinctFailedBrokenPartIds.map((brokenPartId) => ({ brokenPartId })), }, - fm: { - count: async () => args.fmCount, - }, }; return tx as unknown as Tx; } @@ -60,7 +56,6 @@ describe('part-models.getInsights', () => { priceAgg: { sum: null, avg: null, min: null, max: null, count: 0 }, repairCount: 0, distinctFailedBrokenPartIds: [], - fmCount: 0, }); const r = await getInsights(tx, 'nope'); expect(r).toBeNull(); @@ -77,7 +72,6 @@ describe('part-models.getInsights', () => { priceAgg: { sum: 900, avg: 450, min: 100, max: 500, count: 2 }, repairCount: 0, distinctFailedBrokenPartIds: [], - fmCount: 0, }); const r = await getInsights(tx, 'pm'); @@ -98,7 +92,6 @@ describe('part-models.getInsights', () => { priceAgg: { sum: 600, avg: 300, min: 100, max: 500, count: 2 }, repairCount: 0, distinctFailedBrokenPartIds: [], - fmCount: 0, }); const r = await getInsights(tx, 'pm'); @@ -119,7 +112,6 @@ describe('part-models.getInsights', () => { priceAgg: { sum: null, avg: null, min: null, max: null, count: 0 }, repairCount: 0, distinctFailedBrokenPartIds: [], - fmCount: 0, }); const r = await getInsights(tx, 'pm'); @@ -132,23 +124,20 @@ describe('part-models.getInsights', () => { }); }); - it('counts repairs, distinct failed parts, and FMs implicating the model', async () => { + it('counts repairs and distinct failed parts', async () => { const tx = makeTx({ modelExists: true, partCount: 5, stateRows: [], priceAgg: { sum: 0, avg: null, min: null, max: null, count: 0 }, repairCount: 3, - // one part failed twice → 2 distinct broken parts distinctFailedBrokenPartIds: ['part-a', 'part-b'], - fmCount: 2, }); const r = await getInsights(tx, 'pm'); expect(r!.failures).toEqual({ repairs: 3, distinctFailedParts: 2, - fmsImplicating: 2, }); }); }); diff --git a/apps/api/src/services/part-models.ts b/apps/api/src/services/part-models.ts index d061cef..1631c2e 100644 --- a/apps/api/src/services/part-models.ts +++ b/apps/api/src/services/part-models.ts @@ -43,7 +43,7 @@ export async function getInsights(tx: Tx, id: string): Promise ({ @@ -87,7 +86,6 @@ export async function getInsights(tx: Tx, id: string): Promise -
+
{insightsQuery.isPending || !insights ? ( - Array.from({ length: 6 }).map((_, i) => ) + Array.from({ length: 5 }).map((_, i) => ) ) : ( <> @@ -300,10 +300,6 @@ export default function CategoryDetail() { : undefined } /> - )}
diff --git a/apps/web/src/pages/ManufacturerDetail.tsx b/apps/web/src/pages/ManufacturerDetail.tsx index c550839..5a44c3c 100644 --- a/apps/web/src/pages/ManufacturerDetail.tsx +++ b/apps/web/src/pages/ManufacturerDetail.tsx @@ -256,9 +256,9 @@ export default function ManufacturerDetail() {
-
+
{insightsQuery.isPending || !insights ? ( - Array.from({ length: 6 }).map((_, i) => ) + Array.from({ length: 5 }).map((_, i) => ) ) : ( <> @@ -286,10 +286,6 @@ export default function ManufacturerDetail() { : undefined } /> - )}
diff --git a/apps/web/src/pages/PartModelDetail.tsx b/apps/web/src/pages/PartModelDetail.tsx index 5a70d0e..e591ebb 100644 --- a/apps/web/src/pages/PartModelDetail.tsx +++ b/apps/web/src/pages/PartModelDetail.tsx @@ -262,9 +262,9 @@ export default function PartModelDetail() {
-
+
{insightsQuery.isPending || !insights ? ( - Array.from({ length: 5 }).map((_, i) => ) + Array.from({ length: 4 }).map((_, i) => ) ) : ( <> @@ -291,10 +291,6 @@ export default function PartModelDetail() { : undefined } /> - )}
diff --git a/packages/shared/src/category-insights.ts b/packages/shared/src/category-insights.ts index 332fcee..e7124c9 100644 --- a/packages/shared/src/category-insights.ts +++ b/packages/shared/src/category-insights.ts @@ -9,7 +9,6 @@ export interface CategoryPriceStats { export interface CategoryFailureStats { repairs: number; distinctFailedParts: number; - fmsImplicating: number; } export interface CategoryManufacturerCount { diff --git a/packages/shared/src/manufacturer-insights.ts b/packages/shared/src/manufacturer-insights.ts index 61cf687..6fae0ef 100644 --- a/packages/shared/src/manufacturer-insights.ts +++ b/packages/shared/src/manufacturer-insights.ts @@ -9,7 +9,6 @@ export interface ManufacturerPriceStats { export interface ManufacturerFailureStats { repairs: number; distinctFailedParts: number; - fmsImplicating: number; } export interface ManufacturerCategoryCount { diff --git a/packages/shared/src/part-model-insights.ts b/packages/shared/src/part-model-insights.ts index caa66fc..24222ce 100644 --- a/packages/shared/src/part-model-insights.ts +++ b/packages/shared/src/part-model-insights.ts @@ -18,7 +18,6 @@ export interface PartModelPriceStats { export interface PartModelFailureStats { repairs: number; distinctFailedParts: number; - fmsImplicating: number; } export interface PartModelInsights {