New: Show Custom Format score in Manual Import

This commit is contained in:
jack-mil 2023-07-17 23:46:36 -04:00 committed by GitHub
parent 5e19478266
commit 972e140899
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 3 deletions

View File

@ -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) {
<TableRowCell>
{customFormats?.length ? (
<Popover
anchor={<Icon name={icons.INTERACTIVE} />}
title="Formats"
anchor={formatPreferredWordScore(customFormatScore)}
title={translate('CustomFormats')}
body={
<div className={styles.customFormatTooltip}>
<EpisodeFormats formats={customFormats} />

View File

@ -47,6 +47,10 @@ export const defaultState = {
quality: function(item, direction) {
return item.qualityWeight || 0;
},
customFormats: function(item, direction) {
return item.customFormatScore;
}
}
};

View File

@ -29,6 +29,7 @@ namespace Sonarr.Api.V3.ManualImport
public int QualityWeight { get; set; }
public string DownloadId { get; set; }
public List<CustomFormatResource> CustomFormats { get; set; }
public int CustomFormatScore { get; set; }
public IEnumerable<Rejection> 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,