Merge branch 'markus' into kay.one

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

@ -94,9 +94,9 @@ namespace NzbDrone.Core.Test.ProviderTests
public void Trim_Items()
{
//Setup
var historyItem = Builder<History>.CreateListOfSize(20)
var historyItem = Builder<History>.CreateListOfSize(30)
.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();
var mocker = new AutoMoqer();
@ -107,11 +107,13 @@ namespace NzbDrone.Core.Test.ProviderTests
//Act
db.Fetch<History>().Should().HaveCount(20);
db.Fetch<History>().Should().HaveCount(30);
mocker.Resolve<HistoryProvider>().Trim();
//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.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<ConvertEpisodeJob>().InSingletonScope();
Kernel.Bind<IJob>().To<AppUpdateJob>().InSingletonScope();
Kernel.Bind<IJob>().To<TrimLogsJob>().InSingletonScope();
Kernel.Get<JobProvider>().Initialize();
Kernel.Get<WebTimer>().StartTimer(30);

@ -46,5 +46,11 @@ namespace NzbDrone.Core.Instrumentation
_database.Delete<Log>("");
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\HandbrakeProvider.cs" />
<Compile Include="Providers\Indexer\Newznab.cs" />
<Compile Include="Providers\Jobs\TrimLogsJob.cs" />
<Compile Include="Providers\NewznzbProvider.cs" />
<Compile Include="Providers\ExternalNotification\Prowl.cs" />
<Compile Include="Providers\Jobs\AppUpdateJob.cs" />

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

@ -10,6 +10,15 @@
{
padding-top: 20px;
}
.additionalInfo
{
float: right;
margin-top: 20px;
margin-right: 40px;
font-size: 120%;
font-weight: bold;
}
</style>
}
@ -24,11 +33,16 @@
@section MainContent{
<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" }))
{
<h1>Indexers</h1>
<p></p>
@Html.ValidationSummary(true, "Unable to save your settings. Please correct the errors and try again.")
<div>
@{ Html.Telerik().PanelBar()

Loading…
Cancel
Save