fix: cf/qp names instead of ids for entity testing

This commit is contained in:
Sam Chau
2026-01-19 07:58:49 +10:30
parent 6ffc9cd5ce
commit 10244efe91
4 changed files with 25 additions and 16 deletions

View File

@@ -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}

View File

@@ -16,6 +16,7 @@
export let evaluations: Record<number, ReleaseEvaluation>;
export let loadingEntityIds: Set<number> = 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}

View File

@@ -19,6 +19,7 @@
export let releases: TestRelease[];
export let evaluations: Record<number, ReleaseEvaluation>;
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<string | number> = 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 });
}
}
}

View File

@@ -28,12 +28,11 @@ export interface CfScore {
/** Profile CF scores data */
export interface ProfileCfScores {
profileId: number;
scores: Record<number, CfScore>;
profileName: string;
scores: Record<string, CfScore>;
}
/** Custom format info */
export interface CustomFormatInfo {
id: number;
name: string;
}