Signalr errors will not be shown in the UI.

New: Search History, review recent searches and force specific reports to download (Under history)
pull/4/head
Mark McDowall 12 years ago
parent 06df8a86b6
commit 38927e3ca1

@ -41,7 +41,7 @@ namespace NzbDrone.Core.Test.JobTests
[Test] [Test]
public void SeasonSearch_partial_season_success() public void SeasonSearch_partial_season_success()
{ {
var resultItems = Builder<SearchResultItem>.CreateListOfSize(5) var resultItems = Builder<SearchHistoryItem>.CreateListOfSize(5)
.All() .All()
.With(e => e.SearchError = ReportRejectionType.None) .With(e => e.SearchError = ReportRejectionType.None)
.With(e => e.Success = true) .With(e => e.Success = true)

@ -106,7 +106,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
.Returns(ReportRejectionType.None); .Returns(ReportRejectionType.None);
//Act //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 //Assert
result.Should().HaveCount(parseResults.Count); 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); .Setup(s => s.IsSatisfiedBy(It.IsAny<EpisodeParseResult>())).Returns(ReportRejectionType.None);
//Act //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 //Assert
result.Should().HaveCount(parseResults.Count); result.Should().HaveCount(parseResults.Count);
@ -164,7 +164,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
WithQualityNotNeeded(); WithQualityNotNeeded();
//Act //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 //Assert
result.Should().HaveCount(parseResults.Count); result.Should().HaveCount(parseResults.Count);
@ -188,7 +188,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
WithNullSeries(); WithNullSeries();
//Act //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 //Assert
result.Should().HaveCount(parseResults.Count); result.Should().HaveCount(parseResults.Count);
@ -210,7 +210,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
WithMisMatchedSeries(); WithMisMatchedSeries();
//Act //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 //Assert
result.Should().HaveCount(parseResults.Count); result.Should().HaveCount(parseResults.Count);
@ -232,7 +232,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
WithMatchingSeries(); WithMatchingSeries();
//Act //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 //Assert
result.Should().HaveCount(parseResults.Count); result.Should().HaveCount(parseResults.Count);
@ -254,7 +254,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
WithMatchingSeries(); WithMatchingSeries();
//Act //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 //Assert
result.Should().HaveCount(parseResults.Count); result.Should().HaveCount(parseResults.Count);
@ -281,7 +281,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
WithSuccessfulDownload(); WithSuccessfulDownload();
//Act //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 //Assert
result.Should().HaveCount(parseResults.Count); result.Should().HaveCount(parseResults.Count);
@ -315,7 +315,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchProviderTests
.Returns(true); .Returns(true);
//Act //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 //Assert
result.Should().HaveCount(parseResults.Count); result.Should().HaveCount(parseResults.Count);

@ -8,7 +8,7 @@ namespace NzbDrone.Core.Datastore.Migrations
{ {
protected override void MainDbUpgrade() protected override void MainDbUpgrade()
{ {
Database.AddTable("SearchResults", new[] Database.AddTable("SearchHistory", new[]
{ {
new Column("Id", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity), new Column("Id", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity),
new Column("SeriesId", DbType.Int32, ColumnProperty.NotNull), new Column("SeriesId", DbType.Int32, ColumnProperty.NotNull),
@ -18,10 +18,10 @@ namespace NzbDrone.Core.Datastore.Migrations
new Column("SuccessfulDownload", DbType.Boolean, ColumnProperty.NotNull) new Column("SuccessfulDownload", DbType.Boolean, ColumnProperty.NotNull)
}); });
Database.AddTable("SearchResultItems", new[] Database.AddTable("SearchHistoryItems", new[]
{ {
new Column("Id", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity), 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("ReportTitle", DbType.String, ColumnProperty.NotNull),
new Column("Indexer", DbType.String, ColumnProperty.NotNull), new Column("Indexer", DbType.String, ColumnProperty.NotNull),
new Column("NzbUrl", 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\NzbIndex.cs" />
<Compile Include="Providers\Indexer\FileSharingTalk.cs" /> <Compile Include="Providers\Indexer\FileSharingTalk.cs" />
<Compile Include="Providers\Indexer\Wombles.cs" /> <Compile Include="Providers\Indexer\Wombles.cs" />
<Compile Include="Providers\SearchResultProvider.cs" /> <Compile Include="Providers\SearchHistoryProvider.cs" />
<Compile Include="Providers\SeasonProvider.cs" /> <Compile Include="Providers\SeasonProvider.cs" />
<Compile Include="Jobs\RecentBacklogSearchJob.cs" /> <Compile Include="Jobs\RecentBacklogSearchJob.cs" />
<Compile Include="Jobs\TrimLogsJob.cs" /> <Compile Include="Jobs\TrimLogsJob.cs" />
@ -305,8 +305,8 @@
<Compile Include="Providers\AnalyticsProvider.cs"> <Compile Include="Providers\AnalyticsProvider.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Include="Repository\Search\SearchResultItem.cs" /> <Compile Include="Repository\Search\SearchHistoryItem.cs" />
<Compile Include="Repository\Search\SearchResult.cs" /> <Compile Include="Repository\Search\SearchHistory.cs" />
<Compile Include="Model\ReportRejectionType.cs" /> <Compile Include="Model\ReportRejectionType.cs" />
<Compile Include="Repository\Season.cs" /> <Compile Include="Repository\Season.cs" />
<Compile Include="Providers\AutoConfigureProvider.cs"> <Compile Include="Providers\AutoConfigureProvider.cs">

@ -10,7 +10,7 @@ using PetaPoco;
namespace NzbDrone.Core.Providers namespace NzbDrone.Core.Providers
{ {
public class SearchResultProvider public class SearchHistoryProvider
{ {
private readonly IDatabase _database; private readonly IDatabase _database;
private readonly SeriesProvider _seriesProvider; private readonly SeriesProvider _seriesProvider;
@ -20,7 +20,7 @@ namespace NzbDrone.Core.Providers
private static readonly Logger logger = LogManager.GetCurrentClassLogger(); private static readonly Logger logger = LogManager.GetCurrentClassLogger();
[Inject] [Inject]
public SearchResultProvider(IDatabase database, SeriesProvider seriesProvider, public SearchHistoryProvider(IDatabase database, SeriesProvider seriesProvider,
DownloadProvider downloadProvider, EpisodeProvider episodeProvider) DownloadProvider downloadProvider, EpisodeProvider episodeProvider)
{ {
_database = database; _database = database;
@ -29,80 +29,80 @@ namespace NzbDrone.Core.Providers
_episodeProvider = episodeProvider; _episodeProvider = episodeProvider;
} }
public SearchResultProvider() public SearchHistoryProvider()
{ {
} }
public virtual void Add(SearchResult searchResult) public virtual void Add(SearchHistory searchResult)
{ {
logger.Trace("Adding new search result"); 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)); 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"); logger.Trace("Adding search result items");
_database.InsertMany(searchResult.SearchResultItems); _database.InsertMany(searchResult.SearchHistoryItems);
} }
public virtual void Delete(int id) public virtual void Delete(int id)
{ {
logger.Trace("Deleting search result items attached to: {0}", 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); 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, var sql = @"SELECT SearchHistory.Id, SearchHistory.SeriesId, SearchHistory.SeasonNumber,
SearchResults.EpisodeId, SearchResults.SearchTime, SearchHistory.EpisodeId, SearchHistory.SearchTime,
Series.Title as SeriesTitle, Series.IsDaily, Series.Title as SeriesTitle, Series.IsDaily,
Episodes.EpisodeNumber, Episodes.SeasonNumber, Episodes.Title as EpisodeTitle, Episodes.EpisodeNumber, Episodes.SeasonNumber, Episodes.Title as EpisodeTitle,
Episodes.AirDate, Episodes.AirDate,
Count(SearchResultItems.Id) as TotalItems, Count(SearchHistoryItems.Id) as TotalItems,
SUM(CASE WHEN SearchResultItems.Success = 1 THEN 1 ELSE 0 END) as SuccessfulCount SUM(CASE WHEN SearchHistoryItems.Success = 1 THEN 1 ELSE 0 END) as SuccessfulCount
FROM SearchResults FROM SearchHistory
INNER JOIN Series INNER JOIN Series
ON Series.SeriesId = SearchResults.SeriesId ON Series.SeriesId = SearchHistory.SeriesId
LEFT JOIN Episodes LEFT JOIN Episodes
ON Episodes.EpisodeId = SearchResults.EpisodeId ON Episodes.EpisodeId = SearchHistory.EpisodeId
INNER JOIN SearchResultItems INNER JOIN SearchHistoryItems
ON SearchResultItems.SearchResultId = SearchResults.Id ON SearchHistoryItems.SearchHistoryId = SearchHistory.Id
GROUP BY SearchResults.Id, SearchResults.SeriesId, SearchResults.SeasonNumber, GROUP BY SearchHistory.Id, SearchHistory.SeriesId, SearchHistory.SeasonNumber,
SearchResults.EpisodeId, SearchResults.SearchTime, SearchHistory.EpisodeId, SearchHistory.SearchTime,
Series.Title, Series.IsDaily, Series.Title, Series.IsDaily,
Episodes.EpisodeNumber, Episodes.SeasonNumber, Episodes.Title, Episodes.EpisodeNumber, Episodes.SeasonNumber, Episodes.Title,
Episodes.AirDate"; 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, var sql = @"SELECT SearchHistory.Id, SearchHistory.SeriesId, SearchHistory.SeasonNumber,
SearchResults.EpisodeId, SearchResults.SearchTime, SearchHistory.EpisodeId, SearchHistory.SearchTime,
Series.Title as SeriesTitle, Series.IsDaily, Series.Title as SeriesTitle, Series.IsDaily,
Episodes.EpisodeNumber, Episodes.SeasonNumber, Episodes.Title as EpisodeTitle, Episodes.EpisodeNumber, Episodes.SeasonNumber, Episodes.Title as EpisodeTitle,
Episodes.AirDate Episodes.AirDate
FROM SearchResults FROM SearchHistory
INNER JOIN Series INNER JOIN Series
ON Series.SeriesId = SearchResults.SeriesId ON Series.SeriesId = SearchHistory.SeriesId
LEFT JOIN Episodes LEFT JOIN Episodes
ON Episodes.EpisodeId = SearchResults.EpisodeId ON Episodes.EpisodeId = SearchHistory.EpisodeId
WHERE SearchResults.Id = @0"; WHERE SearchHistory.Id = @0";
var result = _database.Single<SearchResult>(sql, id); var result = _database.Single<SearchHistory>(sql, id);
result.SearchResultItems = _database.Fetch<SearchResultItem>("WHERE SearchResultId = @0", id); result.SearchHistoryItems = _database.Fetch<SearchHistoryItem>("WHERE SearchHistoryId = @0", id);
return result; return result;
} }
public virtual void ForceDownload(int itemId) public virtual void ForceDownload(int itemId)
{ {
var item = _database.Single<SearchResultItem>(itemId); var item = _database.Single<SearchHistoryItem>(itemId);
var searchResult = _database.Single<SearchResult>(item.SearchResultId); var searchResult = _database.Single<SearchHistory>(item.SearchHistoryId);
var series = _seriesProvider.GetSeries(searchResult.SeriesId); var series = _seriesProvider.GetSeries(searchResult.SeriesId);
var parseResult = Parser.ParseTitle(item.ReportTitle); var parseResult = Parser.ParseTitle(item.ReportTitle);

@ -22,7 +22,7 @@ namespace NzbDrone.Core.Providers
private readonly SceneMappingProvider _sceneMappingProvider; private readonly SceneMappingProvider _sceneMappingProvider;
private readonly UpgradePossibleSpecification _upgradePossibleSpecification; private readonly UpgradePossibleSpecification _upgradePossibleSpecification;
private readonly AllowedDownloadSpecification _allowedDownloadSpecification; private readonly AllowedDownloadSpecification _allowedDownloadSpecification;
private readonly SearchResultProvider _searchResultProvider; private readonly SearchHistoryProvider _searchHistoryProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
@ -30,7 +30,7 @@ namespace NzbDrone.Core.Providers
public SearchProvider(EpisodeProvider episodeProvider, DownloadProvider downloadProvider, SeriesProvider seriesProvider, public SearchProvider(EpisodeProvider episodeProvider, DownloadProvider downloadProvider, SeriesProvider seriesProvider,
IndexerProvider indexerProvider, SceneMappingProvider sceneMappingProvider, IndexerProvider indexerProvider, SceneMappingProvider sceneMappingProvider,
UpgradePossibleSpecification upgradePossibleSpecification, AllowedDownloadSpecification allowedDownloadSpecification, UpgradePossibleSpecification upgradePossibleSpecification, AllowedDownloadSpecification allowedDownloadSpecification,
SearchResultProvider searchResultProvider) SearchHistoryProvider searchHistoryProvider)
{ {
_episodeProvider = episodeProvider; _episodeProvider = episodeProvider;
_downloadProvider = downloadProvider; _downloadProvider = downloadProvider;
@ -39,7 +39,7 @@ namespace NzbDrone.Core.Providers
_sceneMappingProvider = sceneMappingProvider; _sceneMappingProvider = sceneMappingProvider;
_upgradePossibleSpecification = upgradePossibleSpecification; _upgradePossibleSpecification = upgradePossibleSpecification;
_allowedDownloadSpecification = allowedDownloadSpecification; _allowedDownloadSpecification = allowedDownloadSpecification;
_searchResultProvider = searchResultProvider; _searchHistoryProvider = searchHistoryProvider;
} }
public SearchProvider() public SearchProvider()
@ -48,7 +48,7 @@ namespace NzbDrone.Core.Providers
public virtual bool SeasonSearch(ProgressNotification notification, int seriesId, int seasonNumber) public virtual bool SeasonSearch(ProgressNotification notification, int seriesId, int seasonNumber)
{ {
var searchResult = new SearchResult var searchResult = new SearchHistory
{ {
SearchTime = DateTime.Now, SearchTime = DateTime.Now,
SeriesId = seriesId, SeriesId = seriesId,
@ -91,15 +91,15 @@ namespace NzbDrone.Core.Providers
e => e.EpisodeNumbers = episodeNumbers.ToList() e => e.EpisodeNumbers = episodeNumbers.ToList()
); );
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.Count == episodeNumbers.Count); return (searchResult.Successes.Count == episodeNumbers.Count);
} }
public virtual List<int> PartialSeasonSearch(ProgressNotification notification, int seriesId, int seasonNumber) public virtual List<int> PartialSeasonSearch(ProgressNotification notification, int seriesId, int seasonNumber)
{ {
var searchResult = new SearchResult var searchResult = new SearchHistory
{ {
SearchTime = DateTime.Now, SearchTime = DateTime.Now,
SeriesId = seriesId, SeriesId = seriesId,
@ -127,9 +127,9 @@ namespace NzbDrone.Core.Providers
return new List<int>(); return new List<int>();
notification.CurrentMessage = "Processing search results"; 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; return searchResult.Successes;
} }
@ -160,7 +160,7 @@ namespace NzbDrone.Core.Providers
return false; return false;
} }
var searchResult = new SearchResult var searchResult = new SearchHistory
{ {
SearchTime = DateTime.Now, SearchTime = DateTime.Now,
SeriesId = episode.Series.SeriesId SeriesId = episode.Series.SeriesId
@ -173,20 +173,20 @@ namespace NzbDrone.Core.Providers
if (episode.Series.IsDaily) if (episode.Series.IsDaily)
{ {
searchResult.SearchResultItems = ProcessSearchResults(notification, reports, episode.Series, episode.AirDate.Value); searchResult.SearchHistoryItems = ProcessSearchResults(notification, reports, episode.Series, episode.AirDate.Value);
_searchResultProvider.Add(searchResult); _searchHistoryProvider.Add(searchResult);
if (searchResult.SearchResultItems.Any(r => r.Success)) if (searchResult.SearchHistoryItems.Any(r => r.Success))
return true; return true;
} }
else else
{ {
searchResult.EpisodeId = episodeId; searchResult.EpisodeId = episodeId;
searchResult.SearchResultItems = ProcessSearchResults(notification, reports, searchResult, episode.Series, episode.SeasonNumber, episode.EpisodeNumber); searchResult.SearchHistoryItems = ProcessSearchResults(notification, reports, searchResult, episode.Series, episode.SeasonNumber, episode.EpisodeNumber);
_searchResultProvider.Add(searchResult); _searchHistoryProvider.Add(searchResult);
if (searchResult.SearchResultItems.Any(r => r.Success)) if (searchResult.SearchHistoryItems.Any(r => r.Success))
return true; return true;
} }
@ -257,10 +257,10 @@ namespace NzbDrone.Core.Providers
return reports; 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 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)) 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); Logger.Trace("Analysing report " + episodeParseResult);
var item = new SearchResultItem var item = new SearchHistoryItem
{ {
ReportTitle = episodeParseResult.OriginalString, ReportTitle = episodeParseResult.OriginalString,
NzbUrl = episodeParseResult.NzbUrl, NzbUrl = episodeParseResult.NzbUrl,
@ -353,16 +353,16 @@ namespace NzbDrone.Core.Providers
return items; 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; var skip = false;
foreach (var episodeParseResult in reports.OrderByDescending(c => c.Quality)) foreach (var episodeParseResult in reports.OrderByDescending(c => c.Quality))
{ {
try try
{ {
var item = new SearchResultItem var item = new SearchHistoryItem
{ {
ReportTitle = episodeParseResult.OriginalString, ReportTitle = episodeParseResult.OriginalString,
NzbUrl = episodeParseResult.NzbUrl, NzbUrl = episodeParseResult.NzbUrl,

@ -8,8 +8,8 @@ using PetaPoco;
namespace NzbDrone.Core.Repository.Search namespace NzbDrone.Core.Repository.Search
{ {
[PrimaryKey("Id", autoIncrement = true)] [PrimaryKey("Id", autoIncrement = true)]
[TableName("SearchResults")] [TableName("SearchHistory")]
public class SearchResult public class SearchHistory
{ {
public int Id { get; set; } public int Id { get; set; }
public int SeriesId { get; set; } public int SeriesId { get; set; }
@ -19,7 +19,7 @@ namespace NzbDrone.Core.Repository.Search
public bool SuccessfulDownload { get; set; } public bool SuccessfulDownload { get; set; }
[ResultColumn] [ResultColumn]
public List<SearchResultItem> SearchResultItems { get; set; } public List<SearchHistoryItem> SearchHistoryItems { get; set; }
[Ignore] [Ignore]
public List<int> Successes { get; set; } public List<int> Successes { get; set; }

@ -8,11 +8,11 @@ using PetaPoco;
namespace NzbDrone.Core.Repository.Search namespace NzbDrone.Core.Repository.Search
{ {
[PrimaryKey("Id", autoIncrement = true)] [PrimaryKey("Id", autoIncrement = true)]
[TableName("SearchResultItems")] [TableName("SearchHistoryItems")]
public class SearchResultItem public class SearchHistoryItem
{ {
public int Id { get; set; } public int Id { get; set; }
public int SearchResultId { get; set; } public int SearchHistoryId { get; set; }
public string ReportTitle { get; set; } public string ReportTitle { get; set; }
public string Indexer { get; set; } public string Indexer { get; set; }
public string NzbUrl { get; set; } public string NzbUrl { get; set; }

@ -10,20 +10,20 @@ using NzbDrone.Web.Models;
namespace NzbDrone.Web.Controllers 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() 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, Id = s.Id,
SearchTime = s.SearchTime.ToString(), SearchTime = s.SearchTime.ToString(),
@ -37,13 +37,13 @@ namespace NzbDrone.Web.Controllers
public ActionResult Details(int searchId) public ActionResult Details(int searchId)
{ {
var searchResult = _searchResultProvider.GetSearchResult(searchId); var searchResult = _searchHistoryProvider.GetSearchHistory(searchId);
var model = new SearchDetailsModel var model = new SearchDetailsModel
{ {
Id = searchResult.Id, Id = searchResult.Id,
DisplayName = GetDisplayName(searchResult), DisplayName = GetDisplayName(searchResult),
SearchResultItems = SearchHistoryItems =
searchResult.SearchResultItems.Select(s => new SearchItemModel searchResult.SearchHistoryItems.Select(s => new SearchItemModel
{ {
Id = s.Id, Id = s.Id,
ReportTitle = s.ReportTitle, ReportTitle = s.ReportTitle,
@ -66,12 +66,12 @@ namespace NzbDrone.Web.Controllers
public JsonResult ForceDownload(int id) public JsonResult ForceDownload(int id)
{ {
_searchResultProvider.ForceDownload(id); _searchHistoryProvider.ForceDownload(id);
return new JsonResult { Data = "ok", JsonRequestBehavior = JsonRequestBehavior.AllowGet }; return new JsonResult { Data = "ok", JsonRequestBehavior = JsonRequestBehavior.AllowGet };
} }
public string GetDisplayName(SearchResult searchResult) public string GetDisplayName(SearchHistory searchResult)
{ {
if (!searchResult.EpisodeNumber.HasValue) if (!searchResult.EpisodeNumber.HasValue)
{ {

@ -8,6 +8,6 @@ namespace NzbDrone.Web.Models
{ {
public int Id { get; set; } public int Id { get; set; }
public string DisplayName { 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 namespace NzbDrone.Web.Models
{ {
public class SearchResultsModel public class SearchHistoryModel
{ {
public int Id { get; set; } public int Id { get; set; }
public string DisplayName { get; set; } public string DisplayName { get; set; }

@ -142,7 +142,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="App_Start\DataTablesMvc.cs" /> <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\RequiredIfAnyAttribute.cs" />
<Compile Include="Helpers\Validation\RequiredIfAttribute.cs" /> <Compile Include="Helpers\Validation\RequiredIfAttribute.cs" />
<Content Include="Content\DataTables-1.9.0\media\css\jquery.dataTables.css" /> <Content Include="Content\DataTables-1.9.0\media\css\jquery.dataTables.css" />
@ -241,7 +241,7 @@
<Compile Include="Models\LogModel.cs" /> <Compile Include="Models\LogModel.cs" />
<Compile Include="Models\PostUpgradeModel.cs" /> <Compile Include="Models\PostUpgradeModel.cs" />
<Compile Include="Models\SearchItemModel.cs" /> <Compile Include="Models\SearchItemModel.cs" />
<Compile Include="Models\SearchResultsModel.cs" /> <Compile Include="Models\SearchHistoryModel.cs" />
<Compile Include="Models\UpcomingEpisodesModel.cs" /> <Compile Include="Models\UpcomingEpisodesModel.cs" />
<Compile Include="Models\SeasonModel.cs" /> <Compile Include="Models\SeasonModel.cs" />
<Compile Include="Models\SeriesDetailsModel.cs" /> <Compile Include="Models\SeriesDetailsModel.cs" />
@ -525,10 +525,10 @@
<Content Include="Views\Update\Post.cshtml" /> <Content Include="Views\Update\Post.cshtml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="Views\SearchResult\Index.cshtml" /> <Content Include="Views\SearchHistory\Index.cshtml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="Views\SearchResult\Details.cshtml" /> <Content Include="Views\SearchHistory\Details.cshtml" />
</ItemGroup> </ItemGroup>
<PropertyGroup> <PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion> <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>

@ -34,7 +34,7 @@
jqXHR.error(function (xhr, textStatus, thrownError) { jqXHR.error(function (xhr, textStatus, thrownError) {
//ignore notification errors. //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; return;
alert("Status: " + textStatus + ", Error: " + thrownError); alert("Status: " + textStatus + ", Error: " + thrownError);

@ -4,6 +4,7 @@
<ul class="sub-menu"> <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("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>@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> </ul>
} }

@ -12,7 +12,7 @@
@section Scripts @section Scripts
{ {
@(Html.GridScriptFor(m => m.SearchResultItems, "#searchDetailsGrid") @(Html.GridScriptFor(m => m.SearchHistoryItems, "#searchDetailsGrid")
.PageLength(20) .PageLength(20)
.ChangePageLength(false) .ChangePageLength(false)
.AddColumn(new Column().Image("/Content/Images/Indexers/{Indexer}.png", new { alt = "{Indexer}", title = "{Indexer}" }, "{Indexer}").Sortable(false).Title("").Width("20px")) .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) { function actionColumn(source, type, val) {
if (type === 'display' || type === 'filter') { 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 // 'sort' and 'type' both just use the raw data
return ''; return '';

@ -1,5 +1,5 @@
@using DataTables.Mvc.Core @using DataTables.Mvc.Core
@model IEnumerable<NzbDrone.Web.Models.SearchResultsModel> @model IEnumerable<NzbDrone.Web.Models.SearchHistoryModel>
@{ @{
ViewBag.Title = "Search Results"; ViewBag.Title = "Search Results";
@ -13,7 +13,7 @@
Html.GridScriptForModel("#searchResultsGrid") Html.GridScriptForModel("#searchResultsGrid")
.PageLength(20) .PageLength(20)
.ChangePageLength(false) .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("SearchTime").Title("Time").Width("170px"))
.AddColumn(new Column().DataProperty("ReportCount").Title("Reports Found").Width("140px")) .AddColumn(new Column().DataProperty("ReportCount").Title("Reports Found").Width("140px"))
.AddColumn(new Column().DataProperty("Successful").Title("Successful").Width("110px")) .AddColumn(new Column().DataProperty("Successful").Title("Successful").Width("110px"))
Loading…
Cancel
Save