mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 13:33:34 -07:00
Episode searching now stores the results of the tests.
This commit is contained in:
parent
b9e3d1a921
commit
c7f8f57f77
13 changed files with 314 additions and 81 deletions
60
NzbDrone.Core/Providers/SearchResultProvider.cs
Normal file
60
NzbDrone.Core/Providers/SearchResultProvider.cs
Normal file
|
@ -0,0 +1,60 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using NLog;
|
||||
using Ninject;
|
||||
using NzbDrone.Core.Repository.Search;
|
||||
using PetaPoco;
|
||||
|
||||
namespace NzbDrone.Core.Providers
|
||||
{
|
||||
public class SearchResultProvider
|
||||
{
|
||||
private readonly IDatabase _database;
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
[Inject]
|
||||
public SearchResultProvider(IDatabase database)
|
||||
{
|
||||
_database = database;
|
||||
}
|
||||
|
||||
public SearchResultProvider()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void Add(SearchResult searchResult)
|
||||
{
|
||||
logger.Trace("Adding new search result");
|
||||
var id = Convert.ToInt32(_database.Insert(searchResult));
|
||||
|
||||
searchResult.SearchResultItems.ForEach(s => s.Id = id);
|
||||
logger.Trace("Adding search result items");
|
||||
_database.InsertMany(searchResult.SearchResultItems);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
logger.Trace("Deleting search result: {0}", id);
|
||||
_database.Delete<SearchResult>(id);
|
||||
}
|
||||
|
||||
public virtual List<SearchResult> AllSearchResults()
|
||||
{
|
||||
return _database.Fetch<SearchResult>();
|
||||
}
|
||||
|
||||
public virtual SearchResult GetSearchResult(int id)
|
||||
{
|
||||
var result = _database.Single<SearchResult>(id);
|
||||
result.SearchResultItems = _database.Fetch<SearchResultItem>("WHERE SearchResultId = @0", id);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue