From 10244efe9117db700876931f1c2b72a004ce2efa Mon Sep 17 00:00:00 2001 From: Sam Chau Date: Mon, 19 Jan 2026 07:58:49 +1030 Subject: [PATCH] fix: cf/qp names instead of ids for entity testing --- .../entity-testing/[databaseId]/+page.svelte | 12 ++++++---- .../components/EntityTable.svelte | 2 ++ .../components/ReleaseTable.svelte | 22 +++++++++++-------- .../[databaseId]/components/types.ts | 5 ++--- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/routes/quality-profiles/entity-testing/[databaseId]/+page.svelte b/src/routes/quality-profiles/entity-testing/[databaseId]/+page.svelte index 8cd37e0..92faabe 100644 --- a/src/routes/quality-profiles/entity-testing/[databaseId]/+page.svelte +++ b/src/routes/quality-profiles/entity-testing/[databaseId]/+page.svelte @@ -136,17 +136,20 @@ const evaluation = evaluations[releaseId]; if (!evaluation || !evaluation.cfMatches) return null; - const profileScores = data.cfScoresData.profiles.find((p) => p.profileId === selectedProfileId); + // Get the profile name from the selected ID + const profile = data.qualityProfiles.find((p) => p.id === selectedProfileId); + if (!profile) return null; + + const profileScores = data.cfScoresData.profiles.find((p) => p.profileName === profile.name); if (!profileScores) return null; const arrType = entityType === 'movie' ? 'radarr' : 'sonarr'; let totalScore = 0; - for (const [cfIdStr, matches] of Object.entries(evaluation.cfMatches)) { + for (const [cfName, matches] of Object.entries(evaluation.cfMatches)) { if (!matches) continue; - const cfId = parseInt(cfIdStr, 10); - const cfScore = profileScores.scores[cfId]; + const cfScore = profileScores.scores[cfName]; if (cfScore) { const score = cfScore[arrType]; if (score !== null) { @@ -432,6 +435,7 @@ {evaluations} {loadingEntityIds} {selectedProfileId} + qualityProfiles={data.qualityProfiles} cfScoresData={data.cfScoresData} {calculateScore} {deleteLayer} diff --git a/src/routes/quality-profiles/entity-testing/[databaseId]/components/EntityTable.svelte b/src/routes/quality-profiles/entity-testing/[databaseId]/components/EntityTable.svelte index 06700e6..4fcd5bd 100644 --- a/src/routes/quality-profiles/entity-testing/[databaseId]/components/EntityTable.svelte +++ b/src/routes/quality-profiles/entity-testing/[databaseId]/components/EntityTable.svelte @@ -16,6 +16,7 @@ export let evaluations: Record; export let loadingEntityIds: Set = new Set(); export let selectedProfileId: number | null; + export let qualityProfiles: Array<{ id: number; name: string }>; export let cfScoresData: { customFormats: CustomFormatInfo[]; profiles: ProfileCfScores[] }; export let calculateScore: (releaseId: number, entityType: 'movie' | 'series') => number | null; export let deleteLayer: 'user' | 'base' = 'user'; @@ -194,6 +195,7 @@ releases={row.releases} {evaluations} {selectedProfileId} + {qualityProfiles} {cfScoresData} {calculateScore} deleteLayer={deleteReleaseLayer} diff --git a/src/routes/quality-profiles/entity-testing/[databaseId]/components/ReleaseTable.svelte b/src/routes/quality-profiles/entity-testing/[databaseId]/components/ReleaseTable.svelte index b76bedf..f259baf 100644 --- a/src/routes/quality-profiles/entity-testing/[databaseId]/components/ReleaseTable.svelte +++ b/src/routes/quality-profiles/entity-testing/[databaseId]/components/ReleaseTable.svelte @@ -19,6 +19,7 @@ export let releases: TestRelease[]; export let evaluations: Record; export let selectedProfileId: number | null; + export let qualityProfiles: Array<{ id: number; name: string }>; export let cfScoresData: { customFormats: CustomFormatInfo[]; profiles: ProfileCfScores[] }; export let calculateScore: (releaseId: number, entityType: 'movie' | 'series') => number | null; export let deleteLayer: 'user' | 'base' = 'user'; @@ -27,27 +28,30 @@ let expandedRows: Set = new Set(); // Get matching custom formats for a release with their scores - function getMatchingFormats(releaseId: number): Array<{ id: number; name: string; score: number }> { + function getMatchingFormats(releaseId: number): Array<{ name: string; score: number }> { const evaluation = evaluations[releaseId]; if (!evaluation || !evaluation.cfMatches || !selectedProfileId) return []; - const profileScores = cfScoresData.profiles.find((p) => p.profileId === selectedProfileId); + // Convert profile ID to name for lookup + const profile = qualityProfiles.find((p) => p.id === selectedProfileId); + if (!profile) return []; + + const profileScores = cfScoresData.profiles.find((p) => p.profileName === profile.name); if (!profileScores) return []; const arrType = entityType === 'movie' ? 'radarr' : 'sonarr'; - const matches: Array<{ id: number; name: string; score: number }> = []; + const matches: Array<{ name: string; score: number }> = []; - for (const [cfIdStr, matched] of Object.entries(evaluation.cfMatches)) { + // cfMatches keys are now CF names + for (const [cfName, matched] of Object.entries(evaluation.cfMatches)) { if (!matched) continue; - const cfId = parseInt(cfIdStr, 10); - const cf = cfScoresData.customFormats.find((f) => f.id === cfId); - const cfScore = profileScores.scores[cfId]; + const cfScore = profileScores.scores[cfName]; - if (cf && cfScore) { + if (cfScore) { const score = cfScore[arrType]; if (score !== null && score !== 0) { - matches.push({ id: cfId, name: cf.name, score }); + matches.push({ name: cfName, score }); } } } diff --git a/src/routes/quality-profiles/entity-testing/[databaseId]/components/types.ts b/src/routes/quality-profiles/entity-testing/[databaseId]/components/types.ts index 9517122..e32a684 100644 --- a/src/routes/quality-profiles/entity-testing/[databaseId]/components/types.ts +++ b/src/routes/quality-profiles/entity-testing/[databaseId]/components/types.ts @@ -28,12 +28,11 @@ export interface CfScore { /** Profile CF scores data */ export interface ProfileCfScores { - profileId: number; - scores: Record; + profileName: string; + scores: Record; } /** Custom format info */ export interface CustomFormatInfo { - id: number; name: string; }