From 96f49da79e2ecde29ebccec32261446a0b709133 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sat, 20 Jul 2024 18:44:59 +0300 Subject: [PATCH] New: Improve history details for release grabs --- .../src/History/Details/HistoryDetails.js | 132 +++++++++++++++++- .../History/Details/HistoryDetailsModal.js | 3 + frontend/src/History/HistoryEventTypeCell.js | 24 ++-- frontend/src/History/HistoryRow.js | 4 +- .../Info/History/IndexerHistoryRow.tsx | 3 +- src/NzbDrone.Core/Download/DownloadService.cs | 17 +++ src/NzbDrone.Core/History/HistoryService.cs | 21 ++- .../Indexers/Events/IndexerAuthEvent.cs | 6 +- .../Indexers/Events/IndexerDownloadEvent.cs | 1 + src/NzbDrone.Core/Localization/Core/en.json | 3 + 10 files changed, 194 insertions(+), 20 deletions(-) diff --git a/frontend/src/History/Details/HistoryDetails.js b/frontend/src/History/Details/HistoryDetails.js index 461ccc2d1..42f22f96e 100644 --- a/frontend/src/History/Details/HistoryDetails.js +++ b/frontend/src/History/Details/HistoryDetails.js @@ -3,6 +3,7 @@ import React from 'react'; import DescriptionList from 'Components/DescriptionList/DescriptionList'; import DescriptionListItem from 'Components/DescriptionList/DescriptionListItem'; import Link from 'Components/Link/Link'; +import formatDateTime from 'Utilities/Date/formatDateTime'; import translate from 'Utilities/String/translate'; import styles from './HistoryDetails.css'; @@ -10,7 +11,10 @@ function HistoryDetails(props) { const { indexer, eventType, - data + date, + data, + shortDateFormat, + timeFormat } = props; if (eventType === 'indexerQuery' || eventType === 'indexerRss') { @@ -22,7 +26,9 @@ function HistoryDetails(props) { offset, source, host, - url + url, + elapsedTime, + cached } = data; return ( @@ -104,6 +110,24 @@ function HistoryDetails(props) { /> : null } + + { + elapsedTime ? + : + null + } + + { + date ? + : + null + } ); } @@ -111,10 +135,19 @@ function HistoryDetails(props) { if (eventType === 'releaseGrabbed') { const { source, + host, grabTitle, - url + url, + publishedDate, + infoUrl, + downloadClient, + downloadClientName, + elapsedTime, + grabMethod } = data; + const downloadClientNameInfo = downloadClientName ?? downloadClient; + return ( { @@ -135,6 +168,15 @@ function HistoryDetails(props) { null } + { + data ? + : + null + } + { data ? {infoUrl}} + /> : + null + } + + { + publishedDate ? + : + null + } + + { + downloadClientNameInfo ? + : + null + } + { data ? : null } + + { + elapsedTime ? + : + null + } + + { + grabMethod ? + : + null + } + + { + date ? + : + null + } ); } if (eventType === 'indexerAuth') { + const { elapsedTime } = data; + return ( : null } + + { + elapsedTime ? + : + null + } + + { + date ? + : + null + } ); } @@ -181,6 +297,15 @@ function HistoryDetails(props) { title={translate('Name')} data={data.query} /> + + { + date ? + : + null + } ); } @@ -188,6 +313,7 @@ function HistoryDetails(props) { HistoryDetails.propTypes = { indexer: PropTypes.object.isRequired, eventType: PropTypes.string.isRequired, + date: PropTypes.string.isRequired, data: PropTypes.object.isRequired, shortDateFormat: PropTypes.string.isRequired, timeFormat: PropTypes.string.isRequired diff --git a/frontend/src/History/Details/HistoryDetailsModal.js b/frontend/src/History/Details/HistoryDetailsModal.js index fbc3114ad..560955de3 100644 --- a/frontend/src/History/Details/HistoryDetailsModal.js +++ b/frontend/src/History/Details/HistoryDetailsModal.js @@ -29,6 +29,7 @@ function HistoryDetailsModal(props) { isOpen, eventType, indexer, + date, data, shortDateFormat, timeFormat, @@ -49,6 +50,7 @@ function HistoryDetailsModal(props) { ); } @@ -408,6 +409,7 @@ class HistoryRow extends Component { - + {data.source ? data.source : null} @@ -91,6 +91,7 @@ function IndexerHistoryRow(props: IndexerHistoryRowProps) { x.Id) ?? Array.Empty())); history.Data.Add("Url", message.Url ?? string.Empty); + history.Data.Add("ElapsedTime", message.ElapsedTime.ToString()); + + if (message.Release.InfoUrl.IsNotNullOrWhiteSpace()) + { + history.Data.Add("InfoUrl", message.Release.InfoUrl); + } + + if (message.DownloadClient.IsNotNullOrWhiteSpace() || message.DownloadClientName.IsNotNullOrWhiteSpace()) + { + history.Data.Add("DownloadClient", message.DownloadClient ?? string.Empty); + history.Data.Add("DownloadClientName", message.DownloadClientName ?? string.Empty); + } + + if (message.Release.PublishDate != DateTime.MinValue) + { + history.Data.Add("PublishedDate", message.Release.PublishDate.ToString("s") + "Z"); + } _historyRepository.Insert(history); } @@ -219,7 +236,7 @@ namespace NzbDrone.Core.History Successful = message.Successful }; - history.Data.Add("ElapsedTime", message.Time.ToString()); + history.Data.Add("ElapsedTime", message.ElapsedTime.ToString()); _historyRepository.Insert(history); } diff --git a/src/NzbDrone.Core/Indexers/Events/IndexerAuthEvent.cs b/src/NzbDrone.Core/Indexers/Events/IndexerAuthEvent.cs index ed515b3b0..9a8888ae1 100644 --- a/src/NzbDrone.Core/Indexers/Events/IndexerAuthEvent.cs +++ b/src/NzbDrone.Core/Indexers/Events/IndexerAuthEvent.cs @@ -6,13 +6,13 @@ namespace NzbDrone.Core.Indexers.Events { public int IndexerId { get; set; } public bool Successful { get; set; } - public long Time { get; set; } + public long ElapsedTime { get; set; } - public IndexerAuthEvent(int indexerId, bool successful, long time) + public IndexerAuthEvent(int indexerId, bool successful, long elapsedTime) { IndexerId = indexerId; Successful = successful; - Time = time; + ElapsedTime = elapsedTime; } } } diff --git a/src/NzbDrone.Core/Indexers/Events/IndexerDownloadEvent.cs b/src/NzbDrone.Core/Indexers/Events/IndexerDownloadEvent.cs index 43bf8cd60..d68397562 100644 --- a/src/NzbDrone.Core/Indexers/Events/IndexerDownloadEvent.cs +++ b/src/NzbDrone.Core/Indexers/Events/IndexerDownloadEvent.cs @@ -18,6 +18,7 @@ namespace NzbDrone.Core.Indexers.Events public string DownloadId { get; set; } public IIndexer Indexer { get; set; } public GrabTrigger GrabTrigger { get; set; } + public long ElapsedTime { get; set; } public IndexerDownloadEvent(ReleaseInfo release, bool successful, string source, string host, string title, string url) { diff --git a/src/NzbDrone.Core/Localization/Core/en.json b/src/NzbDrone.Core/Localization/Core/en.json index 13c009408..f6140c2c5 100644 --- a/src/NzbDrone.Core/Localization/Core/en.json +++ b/src/NzbDrone.Core/Localization/Core/en.json @@ -424,6 +424,7 @@ "IndexerVipExpiringHealthCheckMessage": "Indexer VIP benefits expiring soon: {indexerNames}", "Indexers": "Indexers", "Info": "Info", + "InfoUrl": "Info URL", "InitialFailure": "Initial Failure", "InstanceName": "Instance Name", "InstanceNameHelpText": "Instance name in tab and for Syslog app name", @@ -555,6 +556,7 @@ "ProxyValidationBadRequest": "Failed to test proxy. Status code: {statusCode}", "ProxyValidationUnableToConnect": "Unable to connect to proxy: {exceptionMessage}. Check the log surrounding this error for details", "Public": "Public", + "PublishedDate": "Published Date", "Publisher": "Publisher", "Query": "Query", "QueryOptions": "Query Options", @@ -568,6 +570,7 @@ "Reddit": "Reddit", "Redirect": "Redirect", "RedirectHelpText": "Redirect incoming download request for indexer and pass the grab directly instead of proxying the request via {appName}", + "Redirected": "Redirected", "Refresh": "Refresh", "RefreshMovie": "Refresh movie", "ReleaseBranchCheckOfficialBranchMessage": "Branch {0} is not a valid {appName} release branch, you will not receive updates",