From 972e1408993fc4656196087c6646f23d222e41f5 Mon Sep 17 00:00:00 2001 From: jack-mil <62065280+jack-mil@users.noreply.github.com> Date: Mon, 17 Jul 2023 23:46:36 -0400 Subject: [PATCH] New: Show Custom Format score in Manual Import --- .../Interactive/InteractiveImportRow.tsx | 8 ++++++-- frontend/src/Store/Actions/interactiveImportActions.js | 4 ++++ src/Sonarr.Api.V3/ManualImport/ManualImportResource.cs | 7 ++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/frontend/src/InteractiveImport/Interactive/InteractiveImportRow.tsx b/frontend/src/InteractiveImport/Interactive/InteractiveImportRow.tsx index 763d697cb..dd740afef 100644 --- a/frontend/src/InteractiveImport/Interactive/InteractiveImportRow.tsx +++ b/frontend/src/InteractiveImport/Interactive/InteractiveImportRow.tsx @@ -30,6 +30,8 @@ import { import { SelectStateInputProps } from 'typings/props'; import Rejection from 'typings/Rejection'; import formatBytes from 'Utilities/Number/formatBytes'; +import formatPreferredWordScore from 'Utilities/Number/formatPreferredWordScore'; +import translate from 'Utilities/String/translate'; import InteractiveImportRowCellPlaceholder from './InteractiveImportRowCellPlaceholder'; import styles from './InteractiveImportRow.css'; @@ -57,6 +59,7 @@ interface InteractiveImportRowProps { languages?: Language[]; size: number; customFormats?: object[]; + customFormatScore?: number; rejections: Rejection[]; columns: Column[]; episodeFileId?: number; @@ -80,6 +83,7 @@ function InteractiveImportRow(props: InteractiveImportRowProps) { releaseGroup, size, customFormats, + customFormatScore, rejections, isReprocessing, isSelected, @@ -427,8 +431,8 @@ function InteractiveImportRow(props: InteractiveImportRowProps) { {customFormats?.length ? ( } - title="Formats" + anchor={formatPreferredWordScore(customFormatScore)} + title={translate('CustomFormats')} body={
diff --git a/frontend/src/Store/Actions/interactiveImportActions.js b/frontend/src/Store/Actions/interactiveImportActions.js index aae5e0e7b..28ad0f220 100644 --- a/frontend/src/Store/Actions/interactiveImportActions.js +++ b/frontend/src/Store/Actions/interactiveImportActions.js @@ -47,6 +47,10 @@ export const defaultState = { quality: function(item, direction) { return item.qualityWeight || 0; + }, + + customFormats: function(item, direction) { + return item.customFormatScore; } } }; diff --git a/src/Sonarr.Api.V3/ManualImport/ManualImportResource.cs b/src/Sonarr.Api.V3/ManualImport/ManualImportResource.cs index 28e34516b..590a66333 100644 --- a/src/Sonarr.Api.V3/ManualImport/ManualImportResource.cs +++ b/src/Sonarr.Api.V3/ManualImport/ManualImportResource.cs @@ -29,6 +29,7 @@ namespace Sonarr.Api.V3.ManualImport public int QualityWeight { get; set; } public string DownloadId { get; set; } public List CustomFormats { get; set; } + public int CustomFormatScore { get; set; } public IEnumerable Rejections { get; set; } } @@ -41,6 +42,9 @@ namespace Sonarr.Api.V3.ManualImport return null; } + var customFormats = model.CustomFormats; + var customFormatScore = model.Series?.QualityProfile?.Value?.CalculateCustomFormatScore(customFormats) ?? 0; + return new ManualImportResource { Id = HashConverter.GetHashInt31(model.Path), @@ -56,7 +60,8 @@ namespace Sonarr.Api.V3.ManualImport ReleaseGroup = model.ReleaseGroup, Quality = model.Quality, Languages = model.Languages, - CustomFormats = model.CustomFormats.ToResource(false), + CustomFormats = customFormats.ToResource(false), + CustomFormatScore = customFormatScore, // QualityWeight DownloadId = model.DownloadId,