From e8d3e55b9c2043eb61f2ad292b1d4e924777927a Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 12 Dec 2022 23:48:48 -0800 Subject: [PATCH] New: Show updated Custom Format Score in history (cherry picked from commit 6dcfc661a12f4c6f03345235fb5531c866666a6a) Closes #3291 --- frontend/src/Activity/History/HistoryRow.js | 4 +++- .../src/Artist/History/ArtistHistoryModalContent.js | 12 +++++++++++- frontend/src/Artist/History/ArtistHistoryRow.js | 7 +++++++ src/Lidarr.Api.V1/History/HistoryResource.cs | 7 ++++++- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/frontend/src/Activity/History/HistoryRow.js b/frontend/src/Activity/History/HistoryRow.js index 9bac266f4..632355eab 100644 --- a/frontend/src/Activity/History/HistoryRow.js +++ b/frontend/src/Activity/History/HistoryRow.js @@ -58,6 +58,7 @@ class HistoryRow extends Component { track, quality, customFormats, + customFormatScore, qualityCutoffNotMet, eventType, sourceTitle, @@ -186,7 +187,7 @@ class HistoryRow extends Component { key={name} className={styles.customFormatScore} > - {formatPreferredWordScore(data.customFormatScore)} + {formatPreferredWordScore(customFormatScore)} ); } @@ -254,6 +255,7 @@ HistoryRow.propTypes = { track: PropTypes.object, quality: PropTypes.object.isRequired, customFormats: PropTypes.arrayOf(PropTypes.object), + customFormatScore: PropTypes.number.isRequired, qualityCutoffNotMet: PropTypes.bool.isRequired, eventType: PropTypes.string.isRequired, sourceTitle: PropTypes.string.isRequired, diff --git a/frontend/src/Artist/History/ArtistHistoryModalContent.js b/frontend/src/Artist/History/ArtistHistoryModalContent.js index 822516770..5f021ec5b 100644 --- a/frontend/src/Artist/History/ArtistHistoryModalContent.js +++ b/frontend/src/Artist/History/ArtistHistoryModalContent.js @@ -1,6 +1,7 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import Alert from 'Components/Alert'; +import Icon from 'Components/Icon'; import Button from 'Components/Link/Button'; import LoadingIndicator from 'Components/Loading/LoadingIndicator'; import ModalBody from 'Components/Modal/ModalBody'; @@ -9,7 +10,7 @@ import ModalFooter from 'Components/Modal/ModalFooter'; import ModalHeader from 'Components/Modal/ModalHeader'; import Table from 'Components/Table/Table'; import TableBody from 'Components/Table/TableBody'; -import { kinds } from 'Helpers/Props'; +import { icons, kinds } from 'Helpers/Props'; import translate from 'Utilities/String/translate'; import ArtistHistoryRowConnector from './ArtistHistoryRowConnector'; @@ -43,6 +44,15 @@ const columns = [ label: translate('Details'), isVisible: true }, + { + name: 'customFormatScore', + label: React.createElement(Icon, { + name: icons.SCORE, + title: 'Custom format score' + }), + isSortable: true, + isVisible: true + }, { name: 'actions', label: translate('Actions'), diff --git a/frontend/src/Artist/History/ArtistHistoryRow.js b/frontend/src/Artist/History/ArtistHistoryRow.js index ad6956283..ff5d4b711 100644 --- a/frontend/src/Artist/History/ArtistHistoryRow.js +++ b/frontend/src/Artist/History/ArtistHistoryRow.js @@ -11,6 +11,7 @@ import TableRowCell from 'Components/Table/Cells/TableRowCell'; import TableRow from 'Components/Table/TableRow'; import Popover from 'Components/Tooltip/Popover'; import { icons, kinds, tooltipPositions } from 'Helpers/Props'; +import formatPreferredWordScore from 'Utilities/Number/formatPreferredWordScore'; import translate from 'Utilities/String/translate'; import styles from './ArtistHistoryRow.css'; @@ -75,6 +76,7 @@ class ArtistHistoryRow extends Component { sourceTitle, quality, qualityCutoffNotMet, + customFormatScore, date, data, album @@ -129,6 +131,10 @@ class ArtistHistoryRow extends Component { /> + + {formatPreferredWordScore(customFormatScore)} + + { eventType === 'grabbed' && @@ -160,6 +166,7 @@ ArtistHistoryRow.propTypes = { sourceTitle: PropTypes.string.isRequired, quality: PropTypes.object.isRequired, qualityCutoffNotMet: PropTypes.bool.isRequired, + customFormatScore: PropTypes.number.isRequired, date: PropTypes.string.isRequired, data: PropTypes.object.isRequired, fullArtist: PropTypes.bool.isRequired, diff --git a/src/Lidarr.Api.V1/History/HistoryResource.cs b/src/Lidarr.Api.V1/History/HistoryResource.cs index 2b59e9b9f..97efd98ba 100644 --- a/src/Lidarr.Api.V1/History/HistoryResource.cs +++ b/src/Lidarr.Api.V1/History/HistoryResource.cs @@ -19,6 +19,7 @@ namespace Lidarr.Api.V1.History public string SourceTitle { get; set; } public QualityModel Quality { get; set; } public List CustomFormats { get; set; } + public int CustomFormatScore { get; set; } public bool QualityCutoffNotMet { get; set; } public DateTime Date { get; set; } public string DownloadId { get; set; } @@ -41,6 +42,9 @@ namespace Lidarr.Api.V1.History return null; } + var customFormats = formatCalculator.ParseCustomFormat(model, model.Artist); + var customFormatScore = model.Artist?.QualityProfile?.Value?.CalculateCustomFormatScore(customFormats) ?? 0; + return new HistoryResource { Id = model.Id, @@ -50,7 +54,8 @@ namespace Lidarr.Api.V1.History TrackId = model.TrackId, SourceTitle = model.SourceTitle, Quality = model.Quality, - CustomFormats = formatCalculator.ParseCustomFormat(model, model.Artist).ToResource(false), + CustomFormats = customFormats.ToResource(false), + CustomFormatScore = customFormatScore, // QualityCutoffNotMet Date = model.Date,