New: Store call URL in History, Link in UI

pull/633/head
Qstick 3 years ago
parent 1183a0386d
commit 884aecf846

@ -2,6 +2,7 @@ import PropTypes from 'prop-types';
import React from 'react'; import React from 'react';
import DescriptionList from 'Components/DescriptionList/DescriptionList'; import DescriptionList from 'Components/DescriptionList/DescriptionList';
import DescriptionListItem from 'Components/DescriptionList/DescriptionListItem'; import DescriptionListItem from 'Components/DescriptionList/DescriptionListItem';
import Link from 'Components/Link/Link';
import translate from 'Utilities/String/translate'; import translate from 'Utilities/String/translate';
import styles from './HistoryDetails.css'; import styles from './HistoryDetails.css';
@ -17,7 +18,8 @@ function HistoryDetails(props) {
query, query,
queryResults, queryResults,
categories, categories,
source source,
url
} = data; } = data;
return ( return (
@ -59,6 +61,14 @@ function HistoryDetails(props) {
data={source} data={source}
/> />
} }
{
!!data &&
<DescriptionListItem
title={'Url'}
data={url ? <Link to={url}>{translate('Link')}</Link> : '-'}
/>
}
</DescriptionList> </DescriptionList>
); );
} }
@ -66,7 +76,8 @@ function HistoryDetails(props) {
if (eventType === 'releaseGrabbed') { if (eventType === 'releaseGrabbed') {
const { const {
source, source,
title title,
url
} = data; } = data;
return ( return (
@ -94,6 +105,14 @@ function HistoryDetails(props) {
data={title ? title : '-'} data={title ? title : '-'}
/> />
} }
{
!!data &&
<DescriptionListItem
title={'Url'}
data={url ? <Link to={url}>{translate('Link')}</Link> : '-'}
/>
}
</DescriptionList> </DescriptionList>
); );
} }

@ -81,13 +81,13 @@ namespace NzbDrone.Core.Download
catch (ReleaseUnavailableException) catch (ReleaseUnavailableException)
{ {
_logger.Trace("Release {0} no longer available on indexer.", release); _logger.Trace("Release {0} no longer available on indexer.", release);
_eventAggregator.PublishEvent(new IndexerDownloadEvent(release.IndexerId, false, source, host, release.Title, redirect)); _eventAggregator.PublishEvent(new IndexerDownloadEvent(release.IndexerId, false, source, host, release.Title, release.DownloadUrl, redirect));
throw; throw;
} }
catch (DownloadClientRejectedReleaseException) catch (DownloadClientRejectedReleaseException)
{ {
_logger.Trace("Release {0} rejected by download client, possible duplicate.", release); _logger.Trace("Release {0} rejected by download client, possible duplicate.", release);
_eventAggregator.PublishEvent(new IndexerDownloadEvent(release.IndexerId, false, source, host, release.Title, redirect)); _eventAggregator.PublishEvent(new IndexerDownloadEvent(release.IndexerId, false, source, host, release.Title, release.DownloadUrl, redirect));
throw; throw;
} }
catch (ReleaseDownloadException ex) catch (ReleaseDownloadException ex)
@ -102,14 +102,14 @@ namespace NzbDrone.Core.Download
_indexerStatusService.RecordFailure(release.IndexerId); _indexerStatusService.RecordFailure(release.IndexerId);
} }
_eventAggregator.PublishEvent(new IndexerDownloadEvent(release.IndexerId, false, source, host, release.Title, redirect)); _eventAggregator.PublishEvent(new IndexerDownloadEvent(release.IndexerId, false, source, host, release.Title, release.DownloadUrl, redirect));
throw; throw;
} }
_logger.ProgressInfo("Report sent to {0}. {1}", downloadClient.Definition.Name, downloadTitle); _logger.ProgressInfo("Report sent to {0}. {1}", downloadClient.Definition.Name, downloadTitle);
_eventAggregator.PublishEvent(new IndexerDownloadEvent(release.IndexerId, true, source, host, release.Title, redirect)); _eventAggregator.PublishEvent(new IndexerDownloadEvent(release.IndexerId, true, source, host, release.Title, release.DownloadUrl, redirect));
} }
public async Task<byte[]> DownloadReport(string link, int indexerId, string source, string host, string title) public async Task<byte[]> DownloadReport(string link, int indexerId, string source, string host, string title)
@ -135,7 +135,7 @@ namespace NzbDrone.Core.Download
catch (ReleaseUnavailableException) catch (ReleaseUnavailableException)
{ {
_logger.Trace("Release {0} no longer available on indexer.", link); _logger.Trace("Release {0} no longer available on indexer.", link);
_eventAggregator.PublishEvent(new IndexerDownloadEvent(indexerId, success, source, host, title)); _eventAggregator.PublishEvent(new IndexerDownloadEvent(indexerId, success, source, host, title, url.AbsoluteUri));
throw; throw;
} }
catch (ReleaseDownloadException ex) catch (ReleaseDownloadException ex)
@ -150,17 +150,17 @@ namespace NzbDrone.Core.Download
_indexerStatusService.RecordFailure(indexerId); _indexerStatusService.RecordFailure(indexerId);
} }
_eventAggregator.PublishEvent(new IndexerDownloadEvent(indexerId, success, source, host, title)); _eventAggregator.PublishEvent(new IndexerDownloadEvent(indexerId, success, source, host, title, url.AbsoluteUri));
throw; throw;
} }
_eventAggregator.PublishEvent(new IndexerDownloadEvent(indexerId, success, source, host, title)); _eventAggregator.PublishEvent(new IndexerDownloadEvent(indexerId, success, source, host, title, url.AbsoluteUri));
return downloadedBytes; return downloadedBytes;
} }
public void RecordRedirect(string link, int indexerId, string source, string host, string title) public void RecordRedirect(string link, int indexerId, string source, string host, string title)
{ {
_eventAggregator.PublishEvent(new IndexerDownloadEvent(indexerId, true, source, host, title, true)); _eventAggregator.PublishEvent(new IndexerDownloadEvent(indexerId, true, source, host, title, link, true));
} }
} }
} }

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net;
using NLog; using NLog;
using NzbDrone.Core.Configuration; using NzbDrone.Core.Configuration;
using NzbDrone.Core.Datastore; using NzbDrone.Core.Datastore;
@ -115,7 +116,7 @@ namespace NzbDrone.Core.History
Date = DateTime.UtcNow, Date = DateTime.UtcNow,
IndexerId = message.IndexerId, IndexerId = message.IndexerId,
EventType = message.Query.RssSearch ? HistoryEventType.IndexerRss : HistoryEventType.IndexerQuery, EventType = message.Query.RssSearch ? HistoryEventType.IndexerRss : HistoryEventType.IndexerQuery,
Successful = message.Successful Successful = message.QueryResult.Response?.StatusCode == HttpStatusCode.OK
}; };
if (message.Query is MovieSearchCriteria) if (message.Query is MovieSearchCriteria)
@ -148,13 +149,14 @@ namespace NzbDrone.Core.History
history.Data.Add("BookTitle", ((BookSearchCriteria)message.Query).Title ?? string.Empty); history.Data.Add("BookTitle", ((BookSearchCriteria)message.Query).Title ?? string.Empty);
} }
history.Data.Add("ElapsedTime", message.Time.ToString()); history.Data.Add("ElapsedTime", message.QueryResult.Response?.ElapsedTime.ToString() ?? string.Empty);
history.Data.Add("Query", message.Query.SearchTerm ?? string.Empty); history.Data.Add("Query", message.Query.SearchTerm ?? string.Empty);
history.Data.Add("QueryType", message.Query.SearchType ?? string.Empty); history.Data.Add("QueryType", message.Query.SearchType ?? string.Empty);
history.Data.Add("Categories", string.Join(",", message.Query.Categories) ?? string.Empty); history.Data.Add("Categories", string.Join(",", message.Query.Categories) ?? string.Empty);
history.Data.Add("Source", message.Query.Source ?? string.Empty); history.Data.Add("Source", message.Query.Source ?? string.Empty);
history.Data.Add("Host", message.Query.Host ?? string.Empty); history.Data.Add("Host", message.Query.Host ?? string.Empty);
history.Data.Add("QueryResults", message.Results.HasValue ? message.Results.ToString() : null); history.Data.Add("QueryResults", message.QueryResult.Releases?.Count().ToString() ?? string.Empty);
history.Data.Add("Url", message.QueryResult.Response?.Request.Url.FullUri ?? string.Empty);
_historyRepository.Insert(history); _historyRepository.Insert(history);
} }
@ -173,6 +175,7 @@ namespace NzbDrone.Core.History
history.Data.Add("Host", message.Host ?? string.Empty); history.Data.Add("Host", message.Host ?? string.Empty);
history.Data.Add("GrabMethod", message.Redirect ? "Redirect" : "Proxy"); history.Data.Add("GrabMethod", message.Redirect ? "Redirect" : "Proxy");
history.Data.Add("Title", message.Title); history.Data.Add("Title", message.Title);
history.Data.Add("Url", message.Url ?? string.Empty);
_historyRepository.Insert(history); _historyRepository.Insert(history);
} }

@ -188,14 +188,14 @@ namespace NzbDrone.Core.IndexerSearch
foreach (var query in indexerReports.Queries) foreach (var query in indexerReports.Queries)
{ {
_eventAggregator.PublishEvent(new IndexerQueryEvent(indexer.Definition.Id, criteriaBase, query.ElapsedTime, query.StatusCode == 200, query.Releases.Count())); _eventAggregator.PublishEvent(new IndexerQueryEvent(indexer.Definition.Id, criteriaBase, query));
} }
return releases; return releases;
} }
catch (Exception e) catch (Exception e)
{ {
_eventAggregator.PublishEvent(new IndexerQueryEvent(indexer.Definition.Id, criteriaBase, 0, false)); _eventAggregator.PublishEvent(new IndexerQueryEvent(indexer.Definition.Id, criteriaBase, new IndexerQueryResult()));
_logger.Error(e, "Error while searching for {0}", criteriaBase); _logger.Error(e, "Error while searching for {0}", criteriaBase);
} }

@ -10,8 +10,9 @@ namespace NzbDrone.Core.Indexers.Events
public string Host { get; set; } public string Host { get; set; }
public string Title { get; set; } public string Title { get; set; }
public bool Redirect { get; set; } public bool Redirect { get; set; }
public string Url { get; set; }
public IndexerDownloadEvent(int indexerId, bool successful, string source, string host, string title, bool redirect = false) public IndexerDownloadEvent(int indexerId, bool successful, string source, string host, string title, string url, bool redirect = false)
{ {
IndexerId = indexerId; IndexerId = indexerId;
Successful = successful; Successful = successful;
@ -19,6 +20,7 @@ namespace NzbDrone.Core.Indexers.Events
Host = host; Host = host;
Title = title; Title = title;
Redirect = redirect; Redirect = redirect;
Url = url;
} }
} }
} }

@ -7,17 +7,13 @@ namespace NzbDrone.Core.Indexers.Events
{ {
public int IndexerId { get; set; } public int IndexerId { get; set; }
public SearchCriteriaBase Query { get; set; } public SearchCriteriaBase Query { get; set; }
public long Time { get; set; } public IndexerQueryResult QueryResult { get; set; }
public bool Successful { get; set; }
public int? Results { get; set; }
public IndexerQueryEvent(int indexerId, SearchCriteriaBase query, long time, bool successful, int? results = null) public IndexerQueryEvent(int indexerId, SearchCriteriaBase query, IndexerQueryResult result)
{ {
IndexerId = indexerId; IndexerId = indexerId;
Query = query; Query = query;
Time = time; QueryResult = result;
Successful = successful;
Results = results;
} }
} }
} }

@ -220,7 +220,7 @@ namespace NzbDrone.Core.Indexers
} }
catch (TooManyRequestsException ex) catch (TooManyRequestsException ex)
{ {
result.Queries.Add(new IndexerQueryResult { ElapsedTime = ex.Response.ElapsedTime, StatusCode = (int)ex.Response.StatusCode }); result.Queries.Add(new IndexerQueryResult { Response = ex.Response });
if (ex.RetryAfter != TimeSpan.Zero) if (ex.RetryAfter != TimeSpan.Zero)
{ {
@ -235,13 +235,13 @@ namespace NzbDrone.Core.Indexers
} }
catch (HttpException ex) catch (HttpException ex)
{ {
result.Queries.Add(new IndexerQueryResult { ElapsedTime = ex.Response.ElapsedTime, StatusCode = (int)ex.Response.StatusCode }); result.Queries.Add(new IndexerQueryResult { Response = ex.Response });
_indexerStatusService.RecordFailure(Definition.Id); _indexerStatusService.RecordFailure(Definition.Id);
_logger.Warn("{0} {1}", this, ex.Message); _logger.Warn("{0} {1}", this, ex.Message);
} }
catch (RequestLimitReachedException ex) catch (RequestLimitReachedException ex)
{ {
result.Queries.Add(new IndexerQueryResult { ElapsedTime = ex.Response.HttpResponse.ElapsedTime, StatusCode = (int)ex.Response.HttpResponse.StatusCode }); result.Queries.Add(new IndexerQueryResult { Response = ex.Response.HttpResponse });
_indexerStatusService.RecordFailure(Definition.Id, TimeSpan.FromHours(1)); _indexerStatusService.RecordFailure(Definition.Id, TimeSpan.FromHours(1));
_logger.Warn("API Request Limit reached for {0}", this); _logger.Warn("API Request Limit reached for {0}", this);
} }
@ -252,7 +252,7 @@ namespace NzbDrone.Core.Indexers
} }
catch (CloudFlareCaptchaException ex) catch (CloudFlareCaptchaException ex)
{ {
result.Queries.Add(new IndexerQueryResult { ElapsedTime = ex.Response.ElapsedTime, StatusCode = (int)ex.Response.StatusCode }); result.Queries.Add(new IndexerQueryResult { Response = ex.Response });
_indexerStatusService.RecordFailure(Definition.Id); _indexerStatusService.RecordFailure(Definition.Id);
ex.WithData("FeedUrl", url); ex.WithData("FeedUrl", url);
if (ex.IsExpired) if (ex.IsExpired)
@ -266,7 +266,7 @@ namespace NzbDrone.Core.Indexers
} }
catch (IndexerException ex) catch (IndexerException ex)
{ {
result.Queries.Add(new IndexerQueryResult { ElapsedTime = ex.Response.HttpResponse.ElapsedTime, StatusCode = (int)ex.Response.HttpResponse.StatusCode }); result.Queries.Add(new IndexerQueryResult { Response = ex.Response.HttpResponse });
_indexerStatusService.RecordFailure(Definition.Id); _indexerStatusService.RecordFailure(Definition.Id);
_logger.Warn(ex, "{0}", url); _logger.Warn(ex, "{0}", url);
} }
@ -308,8 +308,7 @@ namespace NzbDrone.Core.Indexers
return new IndexerQueryResult return new IndexerQueryResult
{ {
Releases = releases, Releases = releases,
ElapsedTime = response.HttpResponse.ElapsedTime, Response = response.HttpResponse
StatusCode = (int)response.HttpResponse.StatusCode
}; };
} }
catch (Exception ex) catch (Exception ex)

@ -1,4 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using NzbDrone.Common.Http;
using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.Indexers namespace NzbDrone.Core.Indexers
@ -11,7 +12,6 @@ namespace NzbDrone.Core.Indexers
} }
public IList<ReleaseInfo> Releases { get; set; } public IList<ReleaseInfo> Releases { get; set; }
public long ElapsedTime { get; set; } public HttpResponse Response { get; set; }
public int StatusCode { get; set; }
} }
} }

Loading…
Cancel
Save