mirror of
https://github.com/Sonarr/Sonarr.git
synced 2025-02-20 12:43:28 +02:00
Signalr errors will not be shown in the UI.
New: Search History, review recent searches and force specific reports to download (Under history)
This commit is contained in:
parent
06df8a86b6
commit
38927e3ca1
@ -41,7 +41,7 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
[Test]
|
||||
public void SeasonSearch_partial_season_success()
|
||||
{
|
||||
var resultItems = Builder<SearchResultItem>.CreateListOfSize(5)
|
||||
var resultItems = Builder<SearchHistoryItem>.CreateListOfSize(5)
|
||||
.All()
|
||||
.With(e => e.SearchError = ReportRejectionType.None)
|
||||
.With(e => e.Success = true)
|
||||
|
@ -106,7 +106,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
|
||||
.Returns(ReportRejectionType.None);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<SearchProvider>().ProcessSearchResults(new ProgressNotification("Test"), parseResults, new SearchResult(), _matchingSeries, 1, 1);
|
||||
var result = Mocker.Resolve<SearchProvider>().ProcessSearchResults(new ProgressNotification("Test"), parseResults, new SearchHistory(), _matchingSeries, 1, 1);
|
||||
|
||||
//Assert
|
||||
result.Should().HaveCount(parseResults.Count);
|
||||
@ -139,7 +139,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
|
||||
.Setup(s => s.IsSatisfiedBy(It.IsAny<EpisodeParseResult>())).Returns(ReportRejectionType.None);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<SearchProvider>().ProcessSearchResults(MockNotification, parseResults, new SearchResult(), _matchingSeries, 1, 1);
|
||||
var result = Mocker.Resolve<SearchProvider>().ProcessSearchResults(MockNotification, parseResults, new SearchHistory(), _matchingSeries, 1, 1);
|
||||
|
||||
//Assert
|
||||
result.Should().HaveCount(parseResults.Count);
|
||||
@ -164,7 +164,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
|
||||
WithQualityNotNeeded();
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<SearchProvider>().ProcessSearchResults(new ProgressNotification("Test"), parseResults, new SearchResult(), _matchingSeries, 1, 1);
|
||||
var result = Mocker.Resolve<SearchProvider>().ProcessSearchResults(new ProgressNotification("Test"), parseResults, new SearchHistory(), _matchingSeries, 1, 1);
|
||||
|
||||
//Assert
|
||||
result.Should().HaveCount(parseResults.Count);
|
||||
@ -188,7 +188,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
|
||||
WithNullSeries();
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<SearchProvider>().ProcessSearchResults(new ProgressNotification("Test"), parseResults, new SearchResult(), _matchingSeries, 1, 1);
|
||||
var result = Mocker.Resolve<SearchProvider>().ProcessSearchResults(new ProgressNotification("Test"), parseResults, new SearchHistory(), _matchingSeries, 1, 1);
|
||||
|
||||
//Assert
|
||||
result.Should().HaveCount(parseResults.Count);
|
||||
@ -210,7 +210,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
|
||||
WithMisMatchedSeries();
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<SearchProvider>().ProcessSearchResults(new ProgressNotification("Test"), parseResults, new SearchResult(), _matchingSeries, 1, 1);
|
||||
var result = Mocker.Resolve<SearchProvider>().ProcessSearchResults(new ProgressNotification("Test"), parseResults, new SearchHistory(), _matchingSeries, 1, 1);
|
||||
|
||||
//Assert
|
||||
result.Should().HaveCount(parseResults.Count);
|
||||
@ -232,7 +232,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
|
||||
WithMatchingSeries();
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<SearchProvider>().ProcessSearchResults(new ProgressNotification("Test"), parseResults, new SearchResult(), _matchingSeries, 1, 1);
|
||||
var result = Mocker.Resolve<SearchProvider>().ProcessSearchResults(new ProgressNotification("Test"), parseResults, new SearchHistory(), _matchingSeries, 1, 1);
|
||||
|
||||
//Assert
|
||||
result.Should().HaveCount(parseResults.Count);
|
||||
@ -254,7 +254,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
|
||||
WithMatchingSeries();
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<SearchProvider>().ProcessSearchResults(new ProgressNotification("Test"), parseResults, new SearchResult(), _matchingSeries, 1, 1);
|
||||
var result = Mocker.Resolve<SearchProvider>().ProcessSearchResults(new ProgressNotification("Test"), parseResults, new SearchHistory(), _matchingSeries, 1, 1);
|
||||
|
||||
//Assert
|
||||
result.Should().HaveCount(parseResults.Count);
|
||||
@ -281,7 +281,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
|
||||
WithSuccessfulDownload();
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<SearchProvider>().ProcessSearchResults(new ProgressNotification("Test"), parseResults, new SearchResult(), _matchingSeries, 1);
|
||||
var result = Mocker.Resolve<SearchProvider>().ProcessSearchResults(new ProgressNotification("Test"), parseResults, new SearchHistory(), _matchingSeries, 1);
|
||||
|
||||
//Assert
|
||||
result.Should().HaveCount(parseResults.Count);
|
||||
@ -315,7 +315,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
|
||||
.Returns(true);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<SearchProvider>().ProcessSearchResults(new ProgressNotification("Test"), parseResults, new SearchResult(), _matchingSeries, 1);
|
||||
var result = Mocker.Resolve<SearchProvider>().ProcessSearchResults(new ProgressNotification("Test"), parseResults, new SearchHistory(), _matchingSeries, 1);
|
||||
|
||||
//Assert
|
||||
result.Should().HaveCount(parseResults.Count);
|
||||
|
@ -8,7 +8,7 @@ namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Database.AddTable("SearchResults", new[]
|
||||
Database.AddTable("SearchHistory", new[]
|
||||
{
|
||||
new Column("Id", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity),
|
||||
new Column("SeriesId", DbType.Int32, ColumnProperty.NotNull),
|
||||
@ -18,10 +18,10 @@ namespace NzbDrone.Core.Datastore.Migrations
|
||||
new Column("SuccessfulDownload", DbType.Boolean, ColumnProperty.NotNull)
|
||||
});
|
||||
|
||||
Database.AddTable("SearchResultItems", new[]
|
||||
Database.AddTable("SearchHistoryItems", new[]
|
||||
{
|
||||
new Column("Id", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity),
|
||||
new Column("SearchResultId", DbType.Int32, ColumnProperty.NotNull),
|
||||
new Column("SearchHistoryId", DbType.Int32, ColumnProperty.NotNull),
|
||||
new Column("ReportTitle", DbType.String, ColumnProperty.NotNull),
|
||||
new Column("Indexer", DbType.String, ColumnProperty.NotNull),
|
||||
new Column("NzbUrl", DbType.String, ColumnProperty.NotNull),
|
||||
|
@ -277,7 +277,7 @@
|
||||
<Compile Include="Providers\Indexer\NzbIndex.cs" />
|
||||
<Compile Include="Providers\Indexer\FileSharingTalk.cs" />
|
||||
<Compile Include="Providers\Indexer\Wombles.cs" />
|
||||
<Compile Include="Providers\SearchResultProvider.cs" />
|
||||
<Compile Include="Providers\SearchHistoryProvider.cs" />
|
||||
<Compile Include="Providers\SeasonProvider.cs" />
|
||||
<Compile Include="Jobs\RecentBacklogSearchJob.cs" />
|
||||
<Compile Include="Jobs\TrimLogsJob.cs" />
|
||||
@ -305,8 +305,8 @@
|
||||
<Compile Include="Providers\AnalyticsProvider.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Repository\Search\SearchResultItem.cs" />
|
||||
<Compile Include="Repository\Search\SearchResult.cs" />
|
||||
<Compile Include="Repository\Search\SearchHistoryItem.cs" />
|
||||
<Compile Include="Repository\Search\SearchHistory.cs" />
|
||||
<Compile Include="Model\ReportRejectionType.cs" />
|
||||
<Compile Include="Repository\Season.cs" />
|
||||
<Compile Include="Providers\AutoConfigureProvider.cs">
|
||||
|
@ -10,7 +10,7 @@ using PetaPoco;
|
||||
|
||||
namespace NzbDrone.Core.Providers
|
||||
{
|
||||
public class SearchResultProvider
|
||||
public class SearchHistoryProvider
|
||||
{
|
||||
private readonly IDatabase _database;
|
||||
private readonly SeriesProvider _seriesProvider;
|
||||
@ -20,7 +20,7 @@ namespace NzbDrone.Core.Providers
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
[Inject]
|
||||
public SearchResultProvider(IDatabase database, SeriesProvider seriesProvider,
|
||||
public SearchHistoryProvider(IDatabase database, SeriesProvider seriesProvider,
|
||||
DownloadProvider downloadProvider, EpisodeProvider episodeProvider)
|
||||
{
|
||||
_database = database;
|
||||
@ -29,80 +29,80 @@ namespace NzbDrone.Core.Providers
|
||||
_episodeProvider = episodeProvider;
|
||||
}
|
||||
|
||||
public SearchResultProvider()
|
||||
public SearchHistoryProvider()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void Add(SearchResult searchResult)
|
||||
public virtual void Add(SearchHistory searchResult)
|
||||
{
|
||||
logger.Trace("Adding new search result");
|
||||
searchResult.SuccessfulDownload = searchResult.SearchResultItems.Any(s => s.Success);
|
||||
searchResult.SuccessfulDownload = searchResult.SearchHistoryItems.Any(s => s.Success);
|
||||
var id = Convert.ToInt32(_database.Insert(searchResult));
|
||||
|
||||
searchResult.SearchResultItems.ForEach(s => s.SearchResultId = id);
|
||||
searchResult.SearchHistoryItems.ForEach(s => s.SearchHistoryId = id);
|
||||
logger.Trace("Adding search result items");
|
||||
_database.InsertMany(searchResult.SearchResultItems);
|
||||
_database.InsertMany(searchResult.SearchHistoryItems);
|
||||
}
|
||||
|
||||
public virtual void Delete(int id)
|
||||
{
|
||||
logger.Trace("Deleting search result items attached to: {0}", id);
|
||||
_database.Execute("DELETE FROM SearchResultItems WHERE SearchResultId = @0", id);
|
||||
_database.Execute("DELETE FROM SearchHistoryItems WHERE SearchHistoryId = @0", id);
|
||||
|
||||
logger.Trace("Deleting search result: {0}", id);
|
||||
_database.Delete<SearchResult>(id);
|
||||
_database.Delete<SearchHistory>(id);
|
||||
}
|
||||
|
||||
public virtual List<SearchResult> AllSearchResults()
|
||||
public virtual List<SearchHistory> AllSearchHistory()
|
||||
{
|
||||
var sql = @"SELECT SearchResults.Id, SearchResults.SeriesId, SearchResults.SeasonNumber,
|
||||
SearchResults.EpisodeId, SearchResults.SearchTime,
|
||||
var sql = @"SELECT SearchHistory.Id, SearchHistory.SeriesId, SearchHistory.SeasonNumber,
|
||||
SearchHistory.EpisodeId, SearchHistory.SearchTime,
|
||||
Series.Title as SeriesTitle, Series.IsDaily,
|
||||
Episodes.EpisodeNumber, Episodes.SeasonNumber, Episodes.Title as EpisodeTitle,
|
||||
Episodes.AirDate,
|
||||
Count(SearchResultItems.Id) as TotalItems,
|
||||
SUM(CASE WHEN SearchResultItems.Success = 1 THEN 1 ELSE 0 END) as SuccessfulCount
|
||||
FROM SearchResults
|
||||
Count(SearchHistoryItems.Id) as TotalItems,
|
||||
SUM(CASE WHEN SearchHistoryItems.Success = 1 THEN 1 ELSE 0 END) as SuccessfulCount
|
||||
FROM SearchHistory
|
||||
INNER JOIN Series
|
||||
ON Series.SeriesId = SearchResults.SeriesId
|
||||
ON Series.SeriesId = SearchHistory.SeriesId
|
||||
LEFT JOIN Episodes
|
||||
ON Episodes.EpisodeId = SearchResults.EpisodeId
|
||||
INNER JOIN SearchResultItems
|
||||
ON SearchResultItems.SearchResultId = SearchResults.Id
|
||||
GROUP BY SearchResults.Id, SearchResults.SeriesId, SearchResults.SeasonNumber,
|
||||
SearchResults.EpisodeId, SearchResults.SearchTime,
|
||||
ON Episodes.EpisodeId = SearchHistory.EpisodeId
|
||||
INNER JOIN SearchHistoryItems
|
||||
ON SearchHistoryItems.SearchHistoryId = SearchHistory.Id
|
||||
GROUP BY SearchHistory.Id, SearchHistory.SeriesId, SearchHistory.SeasonNumber,
|
||||
SearchHistory.EpisodeId, SearchHistory.SearchTime,
|
||||
Series.Title, Series.IsDaily,
|
||||
Episodes.EpisodeNumber, Episodes.SeasonNumber, Episodes.Title,
|
||||
Episodes.AirDate";
|
||||
|
||||
return _database.Fetch<SearchResult>(sql);
|
||||
return _database.Fetch<SearchHistory>(sql);
|
||||
}
|
||||
|
||||
public virtual SearchResult GetSearchResult(int id)
|
||||
public virtual SearchHistory GetSearchHistory(int id)
|
||||
{
|
||||
var sql = @"SELECT SearchResults.Id, SearchResults.SeriesId, SearchResults.SeasonNumber,
|
||||
SearchResults.EpisodeId, SearchResults.SearchTime,
|
||||
var sql = @"SELECT SearchHistory.Id, SearchHistory.SeriesId, SearchHistory.SeasonNumber,
|
||||
SearchHistory.EpisodeId, SearchHistory.SearchTime,
|
||||
Series.Title as SeriesTitle, Series.IsDaily,
|
||||
Episodes.EpisodeNumber, Episodes.SeasonNumber, Episodes.Title as EpisodeTitle,
|
||||
Episodes.AirDate
|
||||
FROM SearchResults
|
||||
FROM SearchHistory
|
||||
INNER JOIN Series
|
||||
ON Series.SeriesId = SearchResults.SeriesId
|
||||
ON Series.SeriesId = SearchHistory.SeriesId
|
||||
LEFT JOIN Episodes
|
||||
ON Episodes.EpisodeId = SearchResults.EpisodeId
|
||||
WHERE SearchResults.Id = @0";
|
||||
ON Episodes.EpisodeId = SearchHistory.EpisodeId
|
||||
WHERE SearchHistory.Id = @0";
|
||||
|
||||
var result = _database.Single<SearchResult>(sql, id);
|
||||
result.SearchResultItems = _database.Fetch<SearchResultItem>("WHERE SearchResultId = @0", id);
|
||||
var result = _database.Single<SearchHistory>(sql, id);
|
||||
result.SearchHistoryItems = _database.Fetch<SearchHistoryItem>("WHERE SearchHistoryId = @0", id);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public virtual void ForceDownload(int itemId)
|
||||
{
|
||||
var item = _database.Single<SearchResultItem>(itemId);
|
||||
var searchResult = _database.Single<SearchResult>(item.SearchResultId);
|
||||
var item = _database.Single<SearchHistoryItem>(itemId);
|
||||
var searchResult = _database.Single<SearchHistory>(item.SearchHistoryId);
|
||||
var series = _seriesProvider.GetSeries(searchResult.SeriesId);
|
||||
|
||||
var parseResult = Parser.ParseTitle(item.ReportTitle);
|
@ -22,7 +22,7 @@ namespace NzbDrone.Core.Providers
|
||||
private readonly SceneMappingProvider _sceneMappingProvider;
|
||||
private readonly UpgradePossibleSpecification _upgradePossibleSpecification;
|
||||
private readonly AllowedDownloadSpecification _allowedDownloadSpecification;
|
||||
private readonly SearchResultProvider _searchResultProvider;
|
||||
private readonly SearchHistoryProvider _searchHistoryProvider;
|
||||
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
@ -30,7 +30,7 @@ namespace NzbDrone.Core.Providers
|
||||
public SearchProvider(EpisodeProvider episodeProvider, DownloadProvider downloadProvider, SeriesProvider seriesProvider,
|
||||
IndexerProvider indexerProvider, SceneMappingProvider sceneMappingProvider,
|
||||
UpgradePossibleSpecification upgradePossibleSpecification, AllowedDownloadSpecification allowedDownloadSpecification,
|
||||
SearchResultProvider searchResultProvider)
|
||||
SearchHistoryProvider searchHistoryProvider)
|
||||
{
|
||||
_episodeProvider = episodeProvider;
|
||||
_downloadProvider = downloadProvider;
|
||||
@ -39,7 +39,7 @@ namespace NzbDrone.Core.Providers
|
||||
_sceneMappingProvider = sceneMappingProvider;
|
||||
_upgradePossibleSpecification = upgradePossibleSpecification;
|
||||
_allowedDownloadSpecification = allowedDownloadSpecification;
|
||||
_searchResultProvider = searchResultProvider;
|
||||
_searchHistoryProvider = searchHistoryProvider;
|
||||
}
|
||||
|
||||
public SearchProvider()
|
||||
@ -48,7 +48,7 @@ namespace NzbDrone.Core.Providers
|
||||
|
||||
public virtual bool SeasonSearch(ProgressNotification notification, int seriesId, int seasonNumber)
|
||||
{
|
||||
var searchResult = new SearchResult
|
||||
var searchResult = new SearchHistory
|
||||
{
|
||||
SearchTime = DateTime.Now,
|
||||
SeriesId = seriesId,
|
||||
@ -91,15 +91,15 @@ namespace NzbDrone.Core.Providers
|
||||
e => e.EpisodeNumbers = episodeNumbers.ToList()
|
||||
);
|
||||
|
||||
searchResult.SearchResultItems = ProcessSearchResults(notification, reports, searchResult, series, seasonNumber);
|
||||
_searchResultProvider.Add(searchResult);
|
||||
searchResult.SearchHistoryItems = ProcessSearchResults(notification, reports, searchResult, series, seasonNumber);
|
||||
_searchHistoryProvider.Add(searchResult);
|
||||
|
||||
return (searchResult.Successes.Count == episodeNumbers.Count);
|
||||
}
|
||||
|
||||
public virtual List<int> PartialSeasonSearch(ProgressNotification notification, int seriesId, int seasonNumber)
|
||||
{
|
||||
var searchResult = new SearchResult
|
||||
var searchResult = new SearchHistory
|
||||
{
|
||||
SearchTime = DateTime.Now,
|
||||
SeriesId = seriesId,
|
||||
@ -127,9 +127,9 @@ namespace NzbDrone.Core.Providers
|
||||
return new List<int>();
|
||||
|
||||
notification.CurrentMessage = "Processing search results";
|
||||
searchResult.SearchResultItems = ProcessSearchResults(notification, reports, searchResult, series, seasonNumber);
|
||||
searchResult.SearchHistoryItems = ProcessSearchResults(notification, reports, searchResult, series, seasonNumber);
|
||||
|
||||
_searchResultProvider.Add(searchResult);
|
||||
_searchHistoryProvider.Add(searchResult);
|
||||
return searchResult.Successes;
|
||||
}
|
||||
|
||||
@ -160,7 +160,7 @@ namespace NzbDrone.Core.Providers
|
||||
return false;
|
||||
}
|
||||
|
||||
var searchResult = new SearchResult
|
||||
var searchResult = new SearchHistory
|
||||
{
|
||||
SearchTime = DateTime.Now,
|
||||
SeriesId = episode.Series.SeriesId
|
||||
@ -173,20 +173,20 @@ namespace NzbDrone.Core.Providers
|
||||
|
||||
if (episode.Series.IsDaily)
|
||||
{
|
||||
searchResult.SearchResultItems = ProcessSearchResults(notification, reports, episode.Series, episode.AirDate.Value);
|
||||
_searchResultProvider.Add(searchResult);
|
||||
searchResult.SearchHistoryItems = ProcessSearchResults(notification, reports, episode.Series, episode.AirDate.Value);
|
||||
_searchHistoryProvider.Add(searchResult);
|
||||
|
||||
if (searchResult.SearchResultItems.Any(r => r.Success))
|
||||
if (searchResult.SearchHistoryItems.Any(r => r.Success))
|
||||
return true;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
searchResult.EpisodeId = episodeId;
|
||||
searchResult.SearchResultItems = ProcessSearchResults(notification, reports, searchResult, episode.Series, episode.SeasonNumber, episode.EpisodeNumber);
|
||||
_searchResultProvider.Add(searchResult);
|
||||
searchResult.SearchHistoryItems = ProcessSearchResults(notification, reports, searchResult, episode.Series, episode.SeasonNumber, episode.EpisodeNumber);
|
||||
_searchHistoryProvider.Add(searchResult);
|
||||
|
||||
if (searchResult.SearchResultItems.Any(r => r.Success))
|
||||
if (searchResult.SearchHistoryItems.Any(r => r.Success))
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -257,10 +257,10 @@ namespace NzbDrone.Core.Providers
|
||||
return reports;
|
||||
}
|
||||
|
||||
public List<SearchResultItem> ProcessSearchResults(ProgressNotification notification, IEnumerable<EpisodeParseResult> reports, SearchResult searchResult, Series series, int seasonNumber, int? episodeNumber = null)
|
||||
public List<SearchHistoryItem> ProcessSearchResults(ProgressNotification notification, IEnumerable<EpisodeParseResult> reports, SearchHistory searchResult, Series series, int seasonNumber, int? episodeNumber = null)
|
||||
{
|
||||
var successes = new List<int>();
|
||||
var items = new List<SearchResultItem>();
|
||||
var items = new List<SearchHistoryItem>();
|
||||
|
||||
foreach (var episodeParseResult in reports.OrderByDescending(c => c.Quality).ThenBy(c => c.Age))
|
||||
{
|
||||
@ -268,7 +268,7 @@ namespace NzbDrone.Core.Providers
|
||||
{
|
||||
Logger.Trace("Analysing report " + episodeParseResult);
|
||||
|
||||
var item = new SearchResultItem
|
||||
var item = new SearchHistoryItem
|
||||
{
|
||||
ReportTitle = episodeParseResult.OriginalString,
|
||||
NzbUrl = episodeParseResult.NzbUrl,
|
||||
@ -353,16 +353,16 @@ namespace NzbDrone.Core.Providers
|
||||
return items;
|
||||
}
|
||||
|
||||
public List<SearchResultItem> ProcessSearchResults(ProgressNotification notification, IEnumerable<EpisodeParseResult> reports, Series series, DateTime airDate)
|
||||
public List<SearchHistoryItem> ProcessSearchResults(ProgressNotification notification, IEnumerable<EpisodeParseResult> reports, Series series, DateTime airDate)
|
||||
{
|
||||
var items = new List<SearchResultItem>();
|
||||
var items = new List<SearchHistoryItem>();
|
||||
var skip = false;
|
||||
|
||||
foreach (var episodeParseResult in reports.OrderByDescending(c => c.Quality))
|
||||
{
|
||||
try
|
||||
{
|
||||
var item = new SearchResultItem
|
||||
var item = new SearchHistoryItem
|
||||
{
|
||||
ReportTitle = episodeParseResult.OriginalString,
|
||||
NzbUrl = episodeParseResult.NzbUrl,
|
||||
|
@ -8,8 +8,8 @@ using PetaPoco;
|
||||
namespace NzbDrone.Core.Repository.Search
|
||||
{
|
||||
[PrimaryKey("Id", autoIncrement = true)]
|
||||
[TableName("SearchResults")]
|
||||
public class SearchResult
|
||||
[TableName("SearchHistory")]
|
||||
public class SearchHistory
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int SeriesId { get; set; }
|
||||
@ -19,7 +19,7 @@ namespace NzbDrone.Core.Repository.Search
|
||||
public bool SuccessfulDownload { get; set; }
|
||||
|
||||
[ResultColumn]
|
||||
public List<SearchResultItem> SearchResultItems { get; set; }
|
||||
public List<SearchHistoryItem> SearchHistoryItems { get; set; }
|
||||
|
||||
[Ignore]
|
||||
public List<int> Successes { get; set; }
|
@ -8,11 +8,11 @@ using PetaPoco;
|
||||
namespace NzbDrone.Core.Repository.Search
|
||||
{
|
||||
[PrimaryKey("Id", autoIncrement = true)]
|
||||
[TableName("SearchResultItems")]
|
||||
public class SearchResultItem
|
||||
[TableName("SearchHistoryItems")]
|
||||
public class SearchHistoryItem
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int SearchResultId { get; set; }
|
||||
public int SearchHistoryId { get; set; }
|
||||
public string ReportTitle { get; set; }
|
||||
public string Indexer { get; set; }
|
||||
public string NzbUrl { get; set; }
|
@ -10,20 +10,20 @@ using NzbDrone.Web.Models;
|
||||
|
||||
namespace NzbDrone.Web.Controllers
|
||||
{
|
||||
public class SearchResultController : Controller
|
||||
public class SearchHistoryController : Controller
|
||||
{
|
||||
private readonly SearchResultProvider _searchResultProvider;
|
||||
private readonly SearchHistoryProvider _searchHistoryProvider;
|
||||
|
||||
public SearchResultController(SearchResultProvider searchResultProvider)
|
||||
public SearchHistoryController(SearchHistoryProvider searchHistoryProvider)
|
||||
{
|
||||
_searchResultProvider = searchResultProvider;
|
||||
_searchHistoryProvider = searchHistoryProvider;
|
||||
}
|
||||
|
||||
public ActionResult Index()
|
||||
{
|
||||
var results = _searchResultProvider.AllSearchResults();
|
||||
var results = _searchHistoryProvider.AllSearchHistory();
|
||||
|
||||
var model = results.Select(s => new SearchResultsModel
|
||||
var model = results.Select(s => new SearchHistoryModel
|
||||
{
|
||||
Id = s.Id,
|
||||
SearchTime = s.SearchTime.ToString(),
|
||||
@ -37,13 +37,13 @@ namespace NzbDrone.Web.Controllers
|
||||
|
||||
public ActionResult Details(int searchId)
|
||||
{
|
||||
var searchResult = _searchResultProvider.GetSearchResult(searchId);
|
||||
var searchResult = _searchHistoryProvider.GetSearchHistory(searchId);
|
||||
var model = new SearchDetailsModel
|
||||
{
|
||||
Id = searchResult.Id,
|
||||
DisplayName = GetDisplayName(searchResult),
|
||||
SearchResultItems =
|
||||
searchResult.SearchResultItems.Select(s => new SearchItemModel
|
||||
SearchHistoryItems =
|
||||
searchResult.SearchHistoryItems.Select(s => new SearchItemModel
|
||||
{
|
||||
Id = s.Id,
|
||||
ReportTitle = s.ReportTitle,
|
||||
@ -66,12 +66,12 @@ namespace NzbDrone.Web.Controllers
|
||||
|
||||
public JsonResult ForceDownload(int id)
|
||||
{
|
||||
_searchResultProvider.ForceDownload(id);
|
||||
_searchHistoryProvider.ForceDownload(id);
|
||||
|
||||
return new JsonResult { Data = "ok", JsonRequestBehavior = JsonRequestBehavior.AllowGet };
|
||||
}
|
||||
|
||||
public string GetDisplayName(SearchResult searchResult)
|
||||
public string GetDisplayName(SearchHistory searchResult)
|
||||
{
|
||||
if (!searchResult.EpisodeNumber.HasValue)
|
||||
{
|
@ -8,6 +8,6 @@ namespace NzbDrone.Web.Models
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string DisplayName { get; set; }
|
||||
public List<SearchItemModel> SearchResultItems { get; set; }
|
||||
public List<SearchItemModel> SearchHistoryItems { get; set; }
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace NzbDrone.Web.Models
|
||||
{
|
||||
public class SearchResultsModel
|
||||
public class SearchHistoryModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string DisplayName { get; set; }
|
@ -142,7 +142,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="App_Start\DataTablesMvc.cs" />
|
||||
<Compile Include="Controllers\SearchResultController.cs" />
|
||||
<Compile Include="Controllers\SearchHistoryController.cs" />
|
||||
<Compile Include="Helpers\Validation\RequiredIfAnyAttribute.cs" />
|
||||
<Compile Include="Helpers\Validation\RequiredIfAttribute.cs" />
|
||||
<Content Include="Content\DataTables-1.9.0\media\css\jquery.dataTables.css" />
|
||||
@ -241,7 +241,7 @@
|
||||
<Compile Include="Models\LogModel.cs" />
|
||||
<Compile Include="Models\PostUpgradeModel.cs" />
|
||||
<Compile Include="Models\SearchItemModel.cs" />
|
||||
<Compile Include="Models\SearchResultsModel.cs" />
|
||||
<Compile Include="Models\SearchHistoryModel.cs" />
|
||||
<Compile Include="Models\UpcomingEpisodesModel.cs" />
|
||||
<Compile Include="Models\SeasonModel.cs" />
|
||||
<Compile Include="Models\SeriesDetailsModel.cs" />
|
||||
@ -525,10 +525,10 @@
|
||||
<Content Include="Views\Update\Post.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\SearchResult\Index.cshtml" />
|
||||
<Content Include="Views\SearchHistory\Index.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\SearchResult\Details.cshtml" />
|
||||
<Content Include="Views\SearchHistory\Details.cshtml" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
|
@ -34,7 +34,7 @@
|
||||
|
||||
jqXHR.error(function (xhr, textStatus, thrownError) {
|
||||
//ignore notification errors.
|
||||
if (this.url.indexOf("/notification/Comet") === 0 || this.url.indexOf("/Health/Index") === 0)
|
||||
if (this.url.indexOf("/notification/Comet") === 0 || this.url.indexOf("/Health/Index") === 0 || this.url.indexOf("/signalr") === 0)
|
||||
return;
|
||||
|
||||
alert("Status: " + textStatus + ", Error: " + thrownError);
|
||||
|
@ -4,6 +4,7 @@
|
||||
<ul class="sub-menu">
|
||||
<li>@Ajax.ActionLink("Trim History", "Trim", "History", null, new AjaxOptions{ OnSuccess = "reloadGrid", Confirm = "Delete history items older than 30 days?"}, new { Title = "Delete history items older than 30 days" })</li>
|
||||
<li>@Ajax.ActionLink("Purge History", "Purge", "History", null, new AjaxOptions{ OnSuccess = "reloadGrid", Confirm = "Purge all history items?" }, new { Title = "Delete all history items" })</li>
|
||||
<li>@Html.ActionLink("Search Hisotry", "Index", "SearchHistory", null, new { Title = "Review recent searches" })</li>
|
||||
</ul>
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
@section Scripts
|
||||
{
|
||||
@(Html.GridScriptFor(m => m.SearchResultItems, "#searchDetailsGrid")
|
||||
@(Html.GridScriptFor(m => m.SearchHistoryItems, "#searchDetailsGrid")
|
||||
.PageLength(20)
|
||||
.ChangePageLength(false)
|
||||
.AddColumn(new Column().Image("/Content/Images/Indexers/{Indexer}.png", new { alt = "{Indexer}", title = "{Indexer}" }, "{Indexer}").Sortable(false).Title("").Width("20px"))
|
||||
@ -36,7 +36,7 @@
|
||||
|
||||
function actionColumn(source, type, val) {
|
||||
if (type === 'display' || type === 'filter') {
|
||||
return '<a href="/SearchResult/ForceDownload/' + source["Id"] + '" data-ajax="true" data-ajax-confirm="Are you sure?"><img src="/Content/Images/Plus.png" alt="Force" title="Force" class="gridAction"/></a>';
|
||||
return '<a href="/SearchHistory/ForceDownload/' + source["Id"] + '" data-ajax="true" data-ajax-confirm="Are you sure?"><img src="/Content/Images/Plus.png" alt="Force" title="Force" class="gridAction"/></a>';
|
||||
}
|
||||
// 'sort' and 'type' both just use the raw data
|
||||
return '';
|
@ -1,5 +1,5 @@
|
||||
@using DataTables.Mvc.Core
|
||||
@model IEnumerable<NzbDrone.Web.Models.SearchResultsModel>
|
||||
@model IEnumerable<NzbDrone.Web.Models.SearchHistoryModel>
|
||||
|
||||
@{
|
||||
ViewBag.Title = "Search Results";
|
||||
@ -13,7 +13,7 @@
|
||||
Html.GridScriptForModel("#searchResultsGrid")
|
||||
.PageLength(20)
|
||||
.ChangePageLength(false)
|
||||
.AddColumn(new Column().DataProperty("DisplayName").Link("SearchResult/Details?searchId={Id}", "{DisplayName}", null).Title("Name"))
|
||||
.AddColumn(new Column().DataProperty("DisplayName").Link("SearchHistory/Details?searchId={Id}", "{DisplayName}", null).Title("Name"))
|
||||
.AddColumn(new Column().DataProperty("SearchTime").Title("Time").Width("170px"))
|
||||
.AddColumn(new Column().DataProperty("ReportCount").Title("Reports Found").Width("140px"))
|
||||
.AddColumn(new Column().DataProperty("Successful").Title("Successful").Width("110px"))
|
Loading…
x
Reference in New Issue
Block a user