mirror of
https://github.com/Dictionarry-Hub/profilarr.git
synced 2026-01-29 22:10:52 +01:00
feat(tests): add test count to custom formats in list and views
This commit is contained in:
@@ -47,6 +47,21 @@ export async function list(cache: PCDCache): Promise<CustomFormatTableRow[]> {
|
||||
.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<number, number>();
|
||||
for (const tc of testCounts) {
|
||||
testCountMap.set(tc.custom_format_id, Number(tc.count));
|
||||
}
|
||||
|
||||
// Build tags map
|
||||
const tagsMap = new Map<number, Tag[]>();
|
||||
for (const tag of allTags) {
|
||||
@@ -80,6 +95,7 @@ export async function list(cache: PCDCache): Promise<CustomFormatTableRow[]> {
|
||||
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
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ export interface CustomFormatTableRow {
|
||||
description: string | null;
|
||||
tags: Tag[];
|
||||
conditions: ConditionRef[];
|
||||
testCount: number;
|
||||
}
|
||||
|
||||
/** Custom format basic info */
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import type { CustomFormatTableRow } from '$pcd/queries/customFormats';
|
||||
import { Layers } from 'lucide-svelte';
|
||||
import { Layers, FlaskConical } from 'lucide-svelte';
|
||||
import { marked } from 'marked';
|
||||
import { goto } from '$app/navigation';
|
||||
import { page } from '$app/stores';
|
||||
@@ -32,12 +32,23 @@
|
||||
<h3 class="text-sm font-semibold text-neutral-900 dark:text-neutral-100">
|
||||
{format.name}
|
||||
</h3>
|
||||
<div
|
||||
class="flex flex-shrink-0 items-center gap-1 rounded bg-neutral-100 px-1.5 py-0.5 text-xs text-neutral-600 dark:bg-neutral-800 dark:text-neutral-400"
|
||||
title="{format.conditions.length} condition{format.conditions.length !== 1 ? 's' : ''}"
|
||||
>
|
||||
<Layers size={12} />
|
||||
<span>{format.conditions.length}</span>
|
||||
<div class="flex flex-shrink-0 items-center gap-1.5">
|
||||
<div
|
||||
class="flex items-center gap-1 rounded bg-neutral-100 px-1.5 py-0.5 text-xs text-neutral-600 dark:bg-neutral-800 dark:text-neutral-400"
|
||||
title="{format.conditions.length} condition{format.conditions.length !== 1 ? 's' : ''}"
|
||||
>
|
||||
<Layers size={12} />
|
||||
<span>{format.conditions.length}</span>
|
||||
</div>
|
||||
{#if format.testCount > 0}
|
||||
<div
|
||||
class="flex items-center gap-1 rounded bg-neutral-100 px-1.5 py-0.5 text-xs text-neutral-600 dark:bg-neutral-800 dark:text-neutral-400"
|
||||
title="{format.testCount} test{format.testCount !== 1 ? 's' : ''}"
|
||||
>
|
||||
<FlaskConical size={12} />
|
||||
<span>{format.testCount}</span>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{#if format.tags.length > 0}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import Table from '$ui/table/Table.svelte';
|
||||
import type { Column } from '$ui/table/types';
|
||||
import type { CustomFormatTableRow } from '$pcd/queries/customFormats';
|
||||
import { Tag, FileText, Layers } from 'lucide-svelte';
|
||||
import { Tag, FileText, Layers, FlaskConical } from 'lucide-svelte';
|
||||
import { marked } from 'marked';
|
||||
import { goto } from '$app/navigation';
|
||||
import { page } from '$app/stores';
|
||||
@@ -99,6 +99,19 @@
|
||||
}).join('')}</div>`
|
||||
: `<span class="text-neutral-400 text-xs">None</span>`
|
||||
})
|
||||
},
|
||||
{
|
||||
key: 'testCount',
|
||||
header: 'Tests',
|
||||
headerIcon: FlaskConical,
|
||||
align: 'center',
|
||||
width: 'w-20',
|
||||
sortable: true,
|
||||
cell: (row: CustomFormatTableRow) => ({
|
||||
html: row.testCount > 0
|
||||
? `<span class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-neutral-100 text-neutral-700 dark:bg-neutral-800 dark:text-neutral-300">${row.testCount}</span>`
|
||||
: `<span class="text-neutral-400 text-xs">-</span>`
|
||||
})
|
||||
}
|
||||
];
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user