Removed IHistoryProvider.

pull/6/head
Mark McDowall 14 years ago
parent c25af5978d
commit 0d95302aee

@ -67,7 +67,7 @@ namespace NzbDrone.Core
_kernel.Bind<UpcomingEpisodesProvider>().To<UpcomingEpisodesProvider>(); _kernel.Bind<UpcomingEpisodesProvider>().To<UpcomingEpisodesProvider>();
_kernel.Bind<IDiskProvider>().To<DiskProvider>(); _kernel.Bind<IDiskProvider>().To<DiskProvider>();
_kernel.Bind<SabProvider>().ToSelf(); _kernel.Bind<SabProvider>().ToSelf();
_kernel.Bind<IHistoryProvider>().To<HistoryProvider>(); _kernel.Bind<HistoryProvider>().ToSelf();
_kernel.Bind<RootDirProvider>().ToSelf(); _kernel.Bind<RootDirProvider>().ToSelf();
_kernel.Bind<ExternalNotificationProvider>().ToSelf(); _kernel.Bind<ExternalNotificationProvider>().ToSelf();
_kernel.Bind<XbmcProvider>().ToSelf(); _kernel.Bind<XbmcProvider>().ToSelf();

@ -183,7 +183,6 @@
<Compile Include="Providers\Feed\NzbsOrgFeedProvider.cs" /> <Compile Include="Providers\Feed\NzbsOrgFeedProvider.cs" />
<Compile Include="Providers\HistoryProvider.cs" /> <Compile Include="Providers\HistoryProvider.cs" />
<Compile Include="Providers\IBacklogProvider.cs" /> <Compile Include="Providers\IBacklogProvider.cs" />
<Compile Include="Providers\IHistoryProvider.cs" />
<Compile Include="Providers\IIndexerProvider.cs" /> <Compile Include="Providers\IIndexerProvider.cs" />
<Compile Include="Providers\IndexerProvider.cs" /> <Compile Include="Providers\IndexerProvider.cs" />
<Compile Include="Providers\IRenameProvider.cs" /> <Compile Include="Providers\IRenameProvider.cs" />

@ -17,13 +17,13 @@ namespace NzbDrone.Core.Providers
private readonly SeriesProvider _series; private readonly SeriesProvider _series;
private readonly ISeasonProvider _seasons; private readonly ISeasonProvider _seasons;
private readonly TvDbProvider _tvDb; private readonly TvDbProvider _tvDb;
private readonly IHistoryProvider _history; private readonly HistoryProvider _history;
private readonly QualityProvider _quality; private readonly QualityProvider _quality;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public EpisodeProvider(IRepository sonicRepo, SeriesProvider seriesProvider, public EpisodeProvider(IRepository sonicRepo, SeriesProvider seriesProvider,
ISeasonProvider seasonProvider, TvDbProvider tvDbProvider, ISeasonProvider seasonProvider, TvDbProvider tvDbProvider,
IHistoryProvider history, QualityProvider quality) HistoryProvider history, QualityProvider quality)
{ {
_sonicRepo = sonicRepo; _sonicRepo = sonicRepo;
_series = seriesProvider; _series = seriesProvider;

@ -9,7 +9,7 @@ using SubSonic.Repository;
namespace NzbDrone.Core.Providers namespace NzbDrone.Core.Providers
{ {
public class HistoryProvider : IHistoryProvider public class HistoryProvider
{ {
private readonly IRepository _sonicRepo; private readonly IRepository _sonicRepo;
@ -20,34 +20,34 @@ namespace NzbDrone.Core.Providers
_sonicRepo = sonicRepo; _sonicRepo = sonicRepo;
} }
#region IHistoryProvider Members #region HistoryProvider Members
public List<History> AllItems() public virtual List<History> AllItems()
{ {
return _sonicRepo.All<History>().ToList(); return _sonicRepo.All<History>().ToList();
} }
public void Purge() public virtual void Purge()
{ {
var all = _sonicRepo.All<History>(); var all = _sonicRepo.All<History>();
_sonicRepo.DeleteMany(all); _sonicRepo.DeleteMany(all);
Logger.Info("History has been Purged"); Logger.Info("History has been Purged");
} }
public void Trim() public virtual void Trim()
{ {
var old = _sonicRepo.All<History>().Where(h => h.Date < DateTime.Now.AddDays(-30)); var old = _sonicRepo.All<History>().Where(h => h.Date < DateTime.Now.AddDays(-30));
_sonicRepo.DeleteMany(old); _sonicRepo.DeleteMany(old);
Logger.Info("History has been trimmed, items older than 30 days have been removed"); Logger.Info("History has been trimmed, items older than 30 days have been removed");
} }
public void Insert(History item) public virtual void Insert(History item)
{ {
_sonicRepo.Add(item); _sonicRepo.Add(item);
//Logger.Info("Item added to history: {0} - {1}x{2:00}", item.Episode.Series.Title, item.Episode.SeasonNumber, item.Episode.EpisodeNumber); //Logger.Info("Item added to history: {0} - {1}x{2:00}", item.Episode.Series.Title, item.Episode.SeasonNumber, item.Episode.EpisodeNumber);
} }
public bool Exists(int episodeId, QualityTypes quality, bool proper) public virtual bool Exists(int episodeId, QualityTypes quality, bool proper)
{ {
//Looks for the existance of this episode in History //Looks for the existance of this episode in History
if (_sonicRepo.Exists<History>(h => h.EpisodeId == episodeId && (QualityTypes)h.Quality == quality && h.IsProper == proper)) if (_sonicRepo.Exists<History>(h => h.EpisodeId == episodeId && (QualityTypes)h.Quality == quality && h.IsProper == proper))

@ -1,19 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
namespace NzbDrone.Core.Providers
{
public interface IHistoryProvider
{
List<History> AllItems();
void Purge();
void Trim();
void Insert(History item);
bool Exists(int episodeId, QualityTypes quality, bool proper);
}
}

@ -12,9 +12,9 @@ namespace NzbDrone.Web.Controllers
{ {
public class HistoryController : Controller public class HistoryController : Controller
{ {
private IHistoryProvider _historyProvider; private HistoryProvider _historyProvider;
public HistoryController(IHistoryProvider historyProvider) public HistoryController(HistoryProvider historyProvider)
{ {
_historyProvider = historyProvider; _historyProvider = historyProvider;
} }

Loading…
Cancel
Save