Merge branch 'markus' into kay.one

pull/4/head
kay.one 13 years ago
commit a984060533

@ -94,9 +94,9 @@ namespace NzbDrone.Core.Test.ProviderTests
public void Trim_Items() public void Trim_Items()
{ {
//Setup //Setup
var historyItem = Builder<History>.CreateListOfSize(20) var historyItem = Builder<History>.CreateListOfSize(30)
.TheFirst(10).With(c => c.Date = DateTime.Now) .TheFirst(10).With(c => c.Date = DateTime.Now)
.TheNext(10).With(c => c.Date = DateTime.Now.AddDays(-31)) .TheNext(20).With(c => c.Date = DateTime.Now.AddDays(-31))
.Build(); .Build();
var mocker = new AutoMoqer(); var mocker = new AutoMoqer();
@ -107,11 +107,13 @@ namespace NzbDrone.Core.Test.ProviderTests
//Act //Act
db.Fetch<History>().Should().HaveCount(20); db.Fetch<History>().Should().HaveCount(30);
mocker.Resolve<HistoryProvider>().Trim(); mocker.Resolve<HistoryProvider>().Trim();
//Assert //Assert
db.Fetch<History>().Should().HaveCount(10); var result = db.Fetch<History>();
result.Should().HaveCount(10);
result.Should().OnlyContain(s => s.Date > DateTime.Now.AddDays(-30));
} }

@ -222,5 +222,30 @@ namespace NzbDrone.Core.Test.ProviderTests
logs.Items.Should().HaveCount(50); logs.Items.Should().HaveCount(50);
logs.TotalItems.Should().Be(100); logs.TotalItems.Should().Be(100);
} }
[Test]
public void Trim_Logs_should_clear_logs_older_than_30_days()
{
//Setup
var historyItem = Builder<Log>.CreateListOfSize(30)
.TheFirst(20).With(c => c.Time = DateTime.Now)
.TheNext(10).With(c => c.Time = DateTime.Now.AddDays(-31))
.Build();
var mocker = new AutoMoqer();
var db = MockLib.GetEmptyDatabase();
mocker.SetConstant(db);
db.InsertMany(historyItem);
//Act
db.Fetch<Log>().Should().HaveCount(30);
mocker.Resolve<LogProvider>().Trim();
//Assert
var result = db.Fetch<Log>();
result.Should().HaveCount(20);
result.Should().OnlyContain(s => s.Time > DateTime.Now.AddDays(-30));
}
} }
} }

@ -93,6 +93,7 @@ namespace NzbDrone.Core
Kernel.Bind<IJob>().To<BannerDownloadJob>().InSingletonScope(); Kernel.Bind<IJob>().To<BannerDownloadJob>().InSingletonScope();
Kernel.Bind<IJob>().To<ConvertEpisodeJob>().InSingletonScope(); Kernel.Bind<IJob>().To<ConvertEpisodeJob>().InSingletonScope();
Kernel.Bind<IJob>().To<AppUpdateJob>().InSingletonScope(); Kernel.Bind<IJob>().To<AppUpdateJob>().InSingletonScope();
Kernel.Bind<IJob>().To<TrimLogsJob>().InSingletonScope();
Kernel.Get<JobProvider>().Initialize(); Kernel.Get<JobProvider>().Initialize();
Kernel.Get<WebTimer>().StartTimer(30); Kernel.Get<WebTimer>().StartTimer(30);

@ -46,5 +46,11 @@ namespace NzbDrone.Core.Instrumentation
_database.Delete<Log>(""); _database.Delete<Log>("");
Logger.Info("Cleared Log History"); Logger.Info("Cleared Log History");
} }
public void Trim()
{
_database.Delete<Log>("WHERE Time < @0", DateTime.Now.AddDays(-30).Date);
Logger.Info("Logs have been trimmed, events older than 30 days have been removed");
}
} }
} }

@ -222,6 +222,7 @@
<Compile Include="Providers\Converting\AtomicParsleyProvider.cs" /> <Compile Include="Providers\Converting\AtomicParsleyProvider.cs" />
<Compile Include="Providers\Converting\HandbrakeProvider.cs" /> <Compile Include="Providers\Converting\HandbrakeProvider.cs" />
<Compile Include="Providers\Indexer\Newznab.cs" /> <Compile Include="Providers\Indexer\Newznab.cs" />
<Compile Include="Providers\Jobs\TrimLogsJob.cs" />
<Compile Include="Providers\NewznzbProvider.cs" /> <Compile Include="Providers\NewznzbProvider.cs" />
<Compile Include="Providers\ExternalNotification\Prowl.cs" /> <Compile Include="Providers\ExternalNotification\Prowl.cs" />
<Compile Include="Providers\Jobs\AppUpdateJob.cs" /> <Compile Include="Providers\Jobs\AppUpdateJob.cs" />

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using Ninject; using Ninject;
using NLog; using NLog;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;
@ -40,7 +41,7 @@ namespace NzbDrone.Core.Providers.Jobs
IList<Series> seriesToScan; IList<Series> seriesToScan;
if (targetId == 0) if (targetId == 0)
{ {
seriesToScan = _seriesProvider.GetAllSeries().ToList(); seriesToScan = _seriesProvider.GetAllSeries().OrderBy(o => SortHelper.SkipArticles(o.Title)).ToList();
} }
else else
{ {

@ -0,0 +1,35 @@
using System.Diagnostics;
using System.IO;
using NLog;
using NzbDrone.Common;
using NzbDrone.Core.Instrumentation;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers.Core;
namespace NzbDrone.Core.Providers.Jobs
{
public class TrimLogsJob : IJob
{
private readonly LogProvider _logProvider;
public TrimLogsJob(LogProvider logProvider)
{
_logProvider = logProvider;
}
public string Name
{
get { return "Trim Logs Job"; }
}
public int DefaultInterval
{
get { return 1440; }
}
public virtual void Start(ProgressNotification notification, int targetId, int secondaryTargetId)
{
_logProvider.Trim();
}
}
}

@ -1,6 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Ninject; using Ninject;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;
@ -38,7 +39,7 @@ namespace NzbDrone.Core.Providers.Jobs
IList<Series> seriesToUpdate; IList<Series> seriesToUpdate;
if (targetId == 0) if (targetId == 0)
{ {
seriesToUpdate = _seriesProvider.GetAllSeries().ToList(); seriesToUpdate = _seriesProvider.GetAllSeries().OrderBy(o => SortHelper.SkipArticles(o.Title)).ToList();
} }
else else
{ {

@ -10,6 +10,15 @@
{ {
padding-top: 20px; padding-top: 20px;
} }
.additionalInfo
{
float: right;
margin-top: 20px;
margin-right: 40px;
font-size: 120%;
font-weight: bold;
}
</style> </style>
} }
@ -24,6 +33,11 @@
@section MainContent{ @section MainContent{
<div id="stylized"> <div id="stylized">
<div class="additionalInfo">
NzbDrone checks all Indexers every 15 minutes
</div>
@using (Html.BeginForm("SaveIndexers", "Settings", FormMethod.Post, new { id = "form", name = "form", @class = "settingsForm" })) @using (Html.BeginForm("SaveIndexers", "Settings", FormMethod.Post, new { id = "form", name = "form", @class = "settingsForm" }))
{ {
<h1>Indexers</h1> <h1>Indexers</h1>

Loading…
Cancel
Save