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

@ -81,13 +81,13 @@ namespace NzbDrone.Core.Download
catch (ReleaseUnavailableException)
{
_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;
}
catch (DownloadClientRejectedReleaseException)
{
_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;
}
catch (ReleaseDownloadException ex)
@ -102,14 +102,14 @@ namespace NzbDrone.Core.Download
_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;
}
_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)
@ -135,7 +135,7 @@ namespace NzbDrone.Core.Download
catch (ReleaseUnavailableException)
{
_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;
}
catch (ReleaseDownloadException ex)
@ -150,17 +150,17 @@ namespace NzbDrone.Core.Download
_indexerStatusService.RecordFailure(indexerId);
}
_eventAggregator.PublishEvent(new IndexerDownloadEvent(indexerId, success, source, host, title));
_eventAggregator.PublishEvent(new IndexerDownloadEvent(indexerId, success, source, host, title, url.AbsoluteUri));
throw;
}
_eventAggregator.PublishEvent(new IndexerDownloadEvent(indexerId, success, source, host, title));
_eventAggregator.PublishEvent(new IndexerDownloadEvent(indexerId, success, source, host, title, url.AbsoluteUri));
return downloadedBytes;
}
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.Collections.Generic;
using System.Linq;
using System.Net;
using NLog;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Datastore;
@ -115,7 +116,7 @@ namespace NzbDrone.Core.History
Date = DateTime.UtcNow,
IndexerId = message.IndexerId,
EventType = message.Query.RssSearch ? HistoryEventType.IndexerRss : HistoryEventType.IndexerQuery,
Successful = message.Successful
Successful = message.QueryResult.Response?.StatusCode == HttpStatusCode.OK
};
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("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("QueryType", message.Query.SearchType ?? 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("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);
}
@ -173,6 +175,7 @@ namespace NzbDrone.Core.History
history.Data.Add("Host", message.Host ?? string.Empty);
history.Data.Add("GrabMethod", message.Redirect ? "Redirect" : "Proxy");
history.Data.Add("Title", message.Title);
history.Data.Add("Url", message.Url ?? string.Empty);
_historyRepository.Insert(history);
}

@ -188,14 +188,14 @@ namespace NzbDrone.Core.IndexerSearch
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;
}
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);
}

@ -10,8 +10,9 @@ namespace NzbDrone.Core.Indexers.Events
public string Host { get; set; }
public string Title { 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;
Successful = successful;
@ -19,6 +20,7 @@ namespace NzbDrone.Core.Indexers.Events
Host = host;
Title = title;
Redirect = redirect;
Url = url;
}
}
}

@ -7,17 +7,13 @@ namespace NzbDrone.Core.Indexers.Events
{
public int IndexerId { get; set; }
public SearchCriteriaBase Query { get; set; }
public long Time { get; set; }
public bool Successful { get; set; }
public int? Results { get; set; }
public IndexerQueryResult QueryResult { 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;
Query = query;
Time = time;
Successful = successful;
Results = results;
QueryResult = result;
}
}
}

@ -220,7 +220,7 @@ namespace NzbDrone.Core.Indexers
}
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)
{
@ -235,13 +235,13 @@ namespace NzbDrone.Core.Indexers
}
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);
_logger.Warn("{0} {1}", this, ex.Message);
}
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));
_logger.Warn("API Request Limit reached for {0}", this);
}
@ -252,7 +252,7 @@ namespace NzbDrone.Core.Indexers
}
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);
ex.WithData("FeedUrl", url);
if (ex.IsExpired)
@ -266,7 +266,7 @@ namespace NzbDrone.Core.Indexers
}
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);
_logger.Warn(ex, "{0}", url);
}
@ -308,8 +308,7 @@ namespace NzbDrone.Core.Indexers
return new IndexerQueryResult
{
Releases = releases,
ElapsedTime = response.HttpResponse.ElapsedTime,
StatusCode = (int)response.HttpResponse.StatusCode
Response = response.HttpResponse
};
}
catch (Exception ex)

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

Loading…
Cancel
Save