diff --git a/src/lib/server/pcd/queries/customFormats/list.ts b/src/lib/server/pcd/queries/customFormats/list.ts index 3d95b0f..5c1883e 100644 --- a/src/lib/server/pcd/queries/customFormats/list.ts +++ b/src/lib/server/pcd/queries/customFormats/list.ts @@ -47,6 +47,21 @@ export async function list(cache: PCDCache): Promise { .orderBy('name') .execute(); + // 4. Get test counts for all custom formats + const testCounts = await db + .selectFrom('custom_format_tests') + .select(['custom_format_id']) + .select((eb) => eb.fn.count('id').as('count')) + .where('custom_format_id', 'in', formatIds) + .groupBy('custom_format_id') + .execute(); + + // Build test count map + const testCountMap = new Map(); + for (const tc of testCounts) { + testCountMap.set(tc.custom_format_id, Number(tc.count)); + } + // Build tags map const tagsMap = new Map(); for (const tag of allTags) { @@ -80,6 +95,7 @@ export async function list(cache: PCDCache): Promise { name: format.name, description: format.description, tags: tagsMap.get(format.id) || [], - conditions: conditionsMap.get(format.id) || [] + conditions: conditionsMap.get(format.id) || [], + testCount: testCountMap.get(format.id) || 0 })); } diff --git a/src/lib/server/pcd/queries/customFormats/types.ts b/src/lib/server/pcd/queries/customFormats/types.ts index a0a582d..870232a 100644 --- a/src/lib/server/pcd/queries/customFormats/types.ts +++ b/src/lib/server/pcd/queries/customFormats/types.ts @@ -19,6 +19,7 @@ export interface CustomFormatTableRow { description: string | null; tags: Tag[]; conditions: ConditionRef[]; + testCount: number; } /** Custom format basic info */ diff --git a/src/routes/custom-formats/[databaseId]/views/CardView.svelte b/src/routes/custom-formats/[databaseId]/views/CardView.svelte index 54de6fb..c1a105f 100644 --- a/src/routes/custom-formats/[databaseId]/views/CardView.svelte +++ b/src/routes/custom-formats/[databaseId]/views/CardView.svelte @@ -1,6 +1,6 @@