mirror of https://github.com/lidarr/Lidarr
JobProvider moved to PetaPoco.
This commit is contained in:
parent
901db9d58b
commit
9daf1ccfc0
|
@ -21,7 +21,7 @@ namespace NzbDrone.Core.Test
|
|||
IList<IJob> fakeJobs = new List<IJob> { new FakeJob() };
|
||||
var mocker = new AutoMoqer();
|
||||
|
||||
mocker.SetConstant(MockLib.GetEmptyRepository());
|
||||
mocker.SetConstant(MockLib.GetEmptyDatabase());
|
||||
mocker.SetConstant(fakeJobs);
|
||||
|
||||
//Act
|
||||
|
@ -43,7 +43,7 @@ namespace NzbDrone.Core.Test
|
|||
IList<IJob> fakeJobs = new List<IJob> { new BrokenJob() };
|
||||
var mocker = new AutoMoqer();
|
||||
|
||||
mocker.SetConstant(MockLib.GetEmptyRepository());
|
||||
mocker.SetConstant(MockLib.GetEmptyDatabase());
|
||||
mocker.SetConstant(fakeJobs);
|
||||
|
||||
//Act
|
||||
|
@ -67,7 +67,7 @@ namespace NzbDrone.Core.Test
|
|||
IList<IJob> fakeJobs = new List<IJob> { new FakeJob() };
|
||||
var mocker = new AutoMoqer();
|
||||
|
||||
mocker.SetConstant(MockLib.GetEmptyRepository());
|
||||
mocker.SetConstant(MockLib.GetEmptyDatabase());
|
||||
mocker.SetConstant(fakeJobs);
|
||||
|
||||
var timerProvider = mocker.Resolve<JobProvider>();
|
||||
|
@ -88,7 +88,7 @@ namespace NzbDrone.Core.Test
|
|||
IList<IJob> fakeJobs = new List<IJob> { new FakeJob() };
|
||||
var mocker = new AutoMoqer();
|
||||
|
||||
mocker.SetConstant(MockLib.GetEmptyRepository());
|
||||
mocker.SetConstant(MockLib.GetEmptyDatabase());
|
||||
mocker.SetConstant(fakeJobs);
|
||||
|
||||
var timerProvider = mocker.Resolve<JobProvider>();
|
||||
|
@ -110,7 +110,7 @@ namespace NzbDrone.Core.Test
|
|||
IList<IJob> fakeJobs = new List<IJob> { new SlowJob() };
|
||||
var mocker = new AutoMoqer();
|
||||
|
||||
mocker.SetConstant(MockLib.GetEmptyRepository());
|
||||
mocker.SetConstant(MockLib.GetEmptyDatabase());
|
||||
mocker.SetConstant(fakeJobs);
|
||||
|
||||
var timerProvider = mocker.Resolve<JobProvider>();
|
||||
|
@ -133,7 +133,7 @@ namespace NzbDrone.Core.Test
|
|||
IList<IJob> fakeJobs = new List<IJob> { new BrokenJob() };
|
||||
var mocker = new AutoMoqer();
|
||||
|
||||
mocker.SetConstant(MockLib.GetEmptyRepository());
|
||||
mocker.SetConstant(MockLib.GetEmptyDatabase());
|
||||
mocker.SetConstant(fakeJobs);
|
||||
|
||||
var timerProvider = mocker.Resolve<JobProvider>();
|
||||
|
@ -156,7 +156,7 @@ namespace NzbDrone.Core.Test
|
|||
IList<IJob> fakeJobs = new List<IJob> { new SlowJob() };
|
||||
var mocker = new AutoMoqer();
|
||||
|
||||
mocker.SetConstant(MockLib.GetEmptyRepository());
|
||||
mocker.SetConstant(MockLib.GetEmptyDatabase());
|
||||
mocker.SetConstant(fakeJobs);
|
||||
|
||||
var timerProvider = mocker.Resolve<JobProvider>();
|
||||
|
@ -190,7 +190,7 @@ namespace NzbDrone.Core.Test
|
|||
IList<IJob> fakeJobs = new List<IJob> { slowJob };
|
||||
var mocker = new AutoMoqer();
|
||||
|
||||
mocker.SetConstant(MockLib.GetEmptyRepository());
|
||||
mocker.SetConstant(MockLib.GetEmptyDatabase());
|
||||
mocker.SetConstant(fakeJobs);
|
||||
|
||||
var timerProvider = mocker.Resolve<JobProvider>();
|
||||
|
@ -218,7 +218,7 @@ namespace NzbDrone.Core.Test
|
|||
IList<IJob> fakeJobs = new List<IJob> { fakeTimer };
|
||||
var mocker = new AutoMoqer();
|
||||
|
||||
mocker.SetConstant(MockLib.GetEmptyRepository());
|
||||
mocker.SetConstant(MockLib.GetEmptyDatabase());
|
||||
mocker.SetConstant(fakeJobs);
|
||||
|
||||
var timerProvider = mocker.Resolve<JobProvider>();
|
||||
|
@ -242,7 +242,7 @@ namespace NzbDrone.Core.Test
|
|||
[Test]
|
||||
public void Init_Timers_only_registers_once()
|
||||
{
|
||||
var repo = MockLib.GetEmptyRepository();
|
||||
var repo = MockLib.GetEmptyDatabase();
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
|
@ -273,7 +273,7 @@ namespace NzbDrone.Core.Test
|
|||
[Test]
|
||||
public void Init_Timers_sets_interval_0_to_disabled()
|
||||
{
|
||||
var repo = MockLib.GetEmptyRepository();
|
||||
var repo = MockLib.GetEmptyDatabase();
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
|
@ -307,7 +307,7 @@ namespace NzbDrone.Core.Test
|
|||
IList<IJob> fakeJobs = new List<IJob> { new FakeJob() };
|
||||
var mocker = new AutoMoqer();
|
||||
|
||||
mocker.SetConstant(MockLib.GetEmptyRepository());
|
||||
mocker.SetConstant(MockLib.GetEmptyDatabase());
|
||||
mocker.SetConstant(fakeJobs);
|
||||
|
||||
//Act
|
||||
|
@ -325,7 +325,7 @@ namespace NzbDrone.Core.Test
|
|||
[Test]
|
||||
public void Disabled_isnt_run_by_scheduler()
|
||||
{
|
||||
var repo = MockLib.GetEmptyRepository();
|
||||
var repo = MockLib.GetEmptyDatabase();
|
||||
|
||||
|
||||
var disabledJob = new DisabledJob();
|
||||
|
@ -353,7 +353,7 @@ namespace NzbDrone.Core.Test
|
|||
IList<IJob> fakeJobs = new List<IJob> { new FakeJob() };
|
||||
var mocker = new AutoMoqer();
|
||||
|
||||
mocker.SetConstant(MockLib.GetEmptyRepository());
|
||||
mocker.SetConstant(MockLib.GetEmptyDatabase());
|
||||
mocker.SetConstant(fakeJobs);
|
||||
|
||||
//Act
|
||||
|
@ -374,7 +374,7 @@ namespace NzbDrone.Core.Test
|
|||
IList<IJob> fakeJobs = new List<IJob> { new FakeJob() };
|
||||
var mocker = new AutoMoqer();
|
||||
|
||||
mocker.SetConstant(MockLib.GetEmptyRepository());
|
||||
mocker.SetConstant(MockLib.GetEmptyDatabase());
|
||||
mocker.SetConstant(fakeJobs);
|
||||
|
||||
//Act
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace NzbDrone.Core.Datastore.Migrations
|
|||
new Column("QualityProfileId", DbType.Int16, ColumnProperty.NotNull),
|
||||
new Column("SeasonFolder", DbType.Boolean, ColumnProperty.NotNull),
|
||||
new Column("LastInfoSync", DbType.DateTime, ColumnProperty.Null),
|
||||
new Column("LastDiskSync", DbType.DateTime, ColumnProperty.Null),
|
||||
new Column("LastDiskSync", DbType.DateTime, ColumnProperty.Null)
|
||||
});
|
||||
|
||||
Database.AddTable("Episodes", "SQLite", new[]
|
||||
|
@ -67,7 +67,7 @@ namespace NzbDrone.Core.Datastore.Migrations
|
|||
new Column("Ignored", DbType.Boolean, ColumnProperty.NotNull, false),
|
||||
new Column("EpisodeFileId", DbType.Int32, ColumnProperty.Null),
|
||||
new Column("AirDate", DbType.DateTime, ColumnProperty.Null),
|
||||
new Column("GrabDate", DbType.DateTime, ColumnProperty.Null),
|
||||
new Column("GrabDate", DbType.DateTime, ColumnProperty.Null)
|
||||
});
|
||||
|
||||
|
||||
|
@ -88,7 +88,7 @@ namespace NzbDrone.Core.Datastore.Migrations
|
|||
Database.AddTable("Config", "SQLite", new[]
|
||||
{
|
||||
new Column("Key", DbType.String, ColumnProperty.PrimaryKey),
|
||||
new Column("Value", DbType.String, ColumnProperty.NotNull),
|
||||
new Column("Value", DbType.String, ColumnProperty.NotNull)
|
||||
});
|
||||
|
||||
Database.AddTable("History", "SQLite", new[]
|
||||
|
@ -106,7 +106,7 @@ namespace NzbDrone.Core.Datastore.Migrations
|
|||
Database.AddTable("RootDirs", "SQLite", new[]
|
||||
{
|
||||
new Column("Id", DbType.Int32, ColumnProperty.PrimaryKey),
|
||||
new Column("Path", DbType.String, ColumnProperty.NotNull),
|
||||
new Column("Path", DbType.String, ColumnProperty.NotNull)
|
||||
});
|
||||
|
||||
Database.AddTable("ExternalNotificationSettings", "SQLite", new[]
|
||||
|
@ -116,6 +116,17 @@ namespace NzbDrone.Core.Datastore.Migrations
|
|||
new Column("NotifierName", DbType.String, ColumnProperty.NotNull),
|
||||
new Column("Name", DbType.String, ColumnProperty.NotNull)
|
||||
});
|
||||
|
||||
Database.AddTable("JobSettings", "SQLite", new[]
|
||||
{
|
||||
new Column("Id", DbType.Int32, ColumnProperty.PrimaryKey),
|
||||
new Column("Enable", DbType.Boolean, ColumnProperty.NotNull),
|
||||
new Column("TypeName", DbType.String, ColumnProperty.NotNull),
|
||||
new Column("Name", DbType.String, ColumnProperty.NotNull),
|
||||
new Column("Interval", DbType.Int32, ColumnProperty.NotNull),
|
||||
new Column("LastExecution", DbType.DateTime, ColumnProperty.NotNull),
|
||||
new Column("Success", DbType.Boolean, ColumnProperty.NotNull)
|
||||
});
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
|
|
|
@ -7,6 +7,7 @@ using Ninject;
|
|||
using NLog;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
using NzbDrone.Core.Repository;
|
||||
using PetaPoco;
|
||||
using SubSonic.Repository;
|
||||
|
||||
namespace NzbDrone.Core.Providers.Jobs
|
||||
|
@ -14,7 +15,7 @@ namespace NzbDrone.Core.Providers.Jobs
|
|||
public class JobProvider
|
||||
{
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
private readonly IRepository _repository;
|
||||
private readonly IDatabase _database;
|
||||
private readonly NotificationProvider _notificationProvider;
|
||||
private readonly IList<IJob> _jobs;
|
||||
|
||||
|
@ -26,9 +27,9 @@ namespace NzbDrone.Core.Providers.Jobs
|
|||
private ProgressNotification _notification;
|
||||
|
||||
[Inject]
|
||||
public JobProvider(IRepository repository, NotificationProvider notificationProvider, IList<IJob> jobs)
|
||||
public JobProvider(IDatabase database, NotificationProvider notificationProvider, IList<IJob> jobs)
|
||||
{
|
||||
_repository = repository;
|
||||
_database = database;
|
||||
_notificationProvider = notificationProvider;
|
||||
_jobs = jobs;
|
||||
}
|
||||
|
@ -42,7 +43,7 @@ namespace NzbDrone.Core.Providers.Jobs
|
|||
/// <returns></returns>
|
||||
public virtual List<JobSetting> All()
|
||||
{
|
||||
return _repository.All<JobSetting>().ToList();
|
||||
return _database.Fetch<JobSetting>().ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -54,12 +55,12 @@ namespace NzbDrone.Core.Providers.Jobs
|
|||
if (settings.Id == 0)
|
||||
{
|
||||
Logger.Debug("Adding job settings for {0}", settings.Name);
|
||||
_repository.Add(settings);
|
||||
_database.Insert(settings);
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Debug("Updating job settings for {0}", settings.Name);
|
||||
_repository.Update(settings);
|
||||
_database.Update(settings);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
using System;
|
||||
using PetaPoco;
|
||||
using SubSonic.SqlGeneration.Schema;
|
||||
|
||||
namespace NzbDrone.Core.Repository
|
||||
{
|
||||
[TableName("JobSettings")]
|
||||
[PrimaryKey("Id", autoIncrement = true)]
|
||||
public class JobSetting
|
||||
{
|
||||
[SubSonicPrimaryKey(true)]
|
||||
|
|
Loading…
Reference in New Issue