From cc40b7d2f309f17bbbf69098ae06002cf69daacb Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 21 Nov 2011 22:27:08 -0800 Subject: [PATCH 1/5] UpdateInfo and DiskScan jobs will process in Alphabetical order (ignoring articles). --- NzbDrone.Core/Providers/Jobs/DiskScanJob.cs | 3 ++- NzbDrone.Core/Providers/Jobs/UpdateInfoJob.cs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/NzbDrone.Core/Providers/Jobs/DiskScanJob.cs b/NzbDrone.Core/Providers/Jobs/DiskScanJob.cs index 237567d59..2a994ef5f 100644 --- a/NzbDrone.Core/Providers/Jobs/DiskScanJob.cs +++ b/NzbDrone.Core/Providers/Jobs/DiskScanJob.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 seriesToScan; if (targetId == 0) { - seriesToScan = _seriesProvider.GetAllSeries().ToList(); + seriesToScan = _seriesProvider.GetAllSeries().OrderBy(o => SortHelper.SkipArticles(o.Title)).ToList(); } else { diff --git a/NzbDrone.Core/Providers/Jobs/UpdateInfoJob.cs b/NzbDrone.Core/Providers/Jobs/UpdateInfoJob.cs index 59a322a62..a0161b950 100644 --- a/NzbDrone.Core/Providers/Jobs/UpdateInfoJob.cs +++ b/NzbDrone.Core/Providers/Jobs/UpdateInfoJob.cs @@ -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 seriesToUpdate; if (targetId == 0) { - seriesToUpdate = _seriesProvider.GetAllSeries().ToList(); + seriesToUpdate = _seriesProvider.GetAllSeries().OrderBy(o => SortHelper.SkipArticles(o.Title)).ToList(); } else { From cd6076e7f4d7d9838f53a57573c790729bad6360 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 21 Nov 2011 23:14:33 -0800 Subject: [PATCH 2/5] Added message to Indexer settings regarding RSS feeds being checked every 15 minutes. --- NzbDrone.Web/Views/Settings/Indexers.cshtml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/NzbDrone.Web/Views/Settings/Indexers.cshtml b/NzbDrone.Web/Views/Settings/Indexers.cshtml index b7eeb0fa2..481074ae0 100644 --- a/NzbDrone.Web/Views/Settings/Indexers.cshtml +++ b/NzbDrone.Web/Views/Settings/Indexers.cshtml @@ -10,6 +10,15 @@ { padding-top: 20px; } + + .additionalInfo + { + float: right; + margin-top: 20px; + margin-right: 40px; + font-size: 120%; + font-weight: bold; + } } @@ -24,11 +33,16 @@ @section MainContent{
+
+ NzbDrone checks all Indexers every 15 minutes +
+ + @using (Html.BeginForm("SaveIndexers", "Settings", FormMethod.Post, new { id = "form", name = "form", @class = "settingsForm" })) {

Indexers

- + @Html.ValidationSummary(true, "Unable to save your settings. Please correct the errors and try again.")
@{ Html.Telerik().PanelBar() From b02c7066ad41db6558c44561c88a930475e6aa95 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 21 Nov 2011 23:35:11 -0800 Subject: [PATCH 3/5] Trim added to LogProvider. TrimLogsJob added to trim the logs every 24 hours. --- .../ProviderTests/LogProviderTest.cs | 23 ++++++++++++ NzbDrone.Core/CentralDispatch.cs | 1 + NzbDrone.Core/Instrumentation/LogProvider.cs | 6 ++++ NzbDrone.Core/Providers/Jobs/TrimLogsJob.cs | 35 +++++++++++++++++++ 4 files changed, 65 insertions(+) create mode 100644 NzbDrone.Core/Providers/Jobs/TrimLogsJob.cs diff --git a/NzbDrone.Core.Test/ProviderTests/LogProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/LogProviderTest.cs index fc054dbb1..fa14d16d7 100644 --- a/NzbDrone.Core.Test/ProviderTests/LogProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/LogProviderTest.cs @@ -222,5 +222,28 @@ 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.CreateListOfSize(20) + .TheFirst(10).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().Should().HaveCount(20); + mocker.Resolve().Trim(); + + //Assert + db.Fetch().Should().HaveCount(10); + } } } diff --git a/NzbDrone.Core/CentralDispatch.cs b/NzbDrone.Core/CentralDispatch.cs index 1e0fd30cb..121a300e2 100644 --- a/NzbDrone.Core/CentralDispatch.cs +++ b/NzbDrone.Core/CentralDispatch.cs @@ -93,6 +93,7 @@ namespace NzbDrone.Core Kernel.Bind().To().InSingletonScope(); Kernel.Bind().To().InSingletonScope(); Kernel.Bind().To().InSingletonScope(); + Kernel.Bind().To().InSingletonScope(); Kernel.Get().Initialize(); Kernel.Get().StartTimer(30); diff --git a/NzbDrone.Core/Instrumentation/LogProvider.cs b/NzbDrone.Core/Instrumentation/LogProvider.cs index 07fdcab98..5245a3ce8 100644 --- a/NzbDrone.Core/Instrumentation/LogProvider.cs +++ b/NzbDrone.Core/Instrumentation/LogProvider.cs @@ -46,5 +46,11 @@ namespace NzbDrone.Core.Instrumentation _database.Delete(""); Logger.Info("Cleared Log History"); } + + public void Trim() + { + _database.Delete("WHERE Time < @0", DateTime.Now.AddDays(-30).Date); + Logger.Info("Logs have been trimmed, events older than 30 days have been removed"); + } } } \ No newline at end of file diff --git a/NzbDrone.Core/Providers/Jobs/TrimLogsJob.cs b/NzbDrone.Core/Providers/Jobs/TrimLogsJob.cs new file mode 100644 index 000000000..8dedcbcc9 --- /dev/null +++ b/NzbDrone.Core/Providers/Jobs/TrimLogsJob.cs @@ -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(); + } + } +} \ No newline at end of file From 6ae341373ffe1e0627ae9970a145ab099e1fa66f Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 21 Nov 2011 23:38:02 -0800 Subject: [PATCH 4/5] Missed in last commit. --- NzbDrone.Core/NzbDrone.Core.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index 9044ead71..8a9571ce6 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -218,6 +218,7 @@ + From 519172dfabea1dc56b4f89579b5ee5be984e91c0 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Tue, 22 Nov 2011 17:09:06 -0800 Subject: [PATCH 5/5] Fixed tests to ensure they have different numbers for expected count vs unexpected. --- .../ProviderTests/HistoryProviderTest.cs | 10 ++++++---- NzbDrone.Core.Test/ProviderTests/LogProviderTest.cs | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/NzbDrone.Core.Test/ProviderTests/HistoryProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/HistoryProviderTest.cs index e32d860ba..d1a11e420 100644 --- a/NzbDrone.Core.Test/ProviderTests/HistoryProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/HistoryProviderTest.cs @@ -94,9 +94,9 @@ namespace NzbDrone.Core.Test.ProviderTests public void Trim_Items() { //Setup - var historyItem = Builder.CreateListOfSize(20) + var historyItem = Builder.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().Should().HaveCount(20); + db.Fetch().Should().HaveCount(30); mocker.Resolve().Trim(); //Assert - db.Fetch().Should().HaveCount(10); + var result = db.Fetch(); + result.Should().HaveCount(10); + result.Should().OnlyContain(s => s.Date > DateTime.Now.AddDays(-30)); } diff --git a/NzbDrone.Core.Test/ProviderTests/LogProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/LogProviderTest.cs index fa14d16d7..152106f1a 100644 --- a/NzbDrone.Core.Test/ProviderTests/LogProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/LogProviderTest.cs @@ -227,8 +227,8 @@ namespace NzbDrone.Core.Test.ProviderTests public void Trim_Logs_should_clear_logs_older_than_30_days() { //Setup - var historyItem = Builder.CreateListOfSize(20) - .TheFirst(10).With(c => c.Time = DateTime.Now) + var historyItem = Builder.CreateListOfSize(30) + .TheFirst(20).With(c => c.Time = DateTime.Now) .TheNext(10).With(c => c.Time = DateTime.Now.AddDays(-31)) .Build(); @@ -239,11 +239,13 @@ namespace NzbDrone.Core.Test.ProviderTests db.InsertMany(historyItem); //Act - db.Fetch().Should().HaveCount(20); + db.Fetch().Should().HaveCount(30); mocker.Resolve().Trim(); //Assert - db.Fetch().Should().HaveCount(10); + var result = db.Fetch(); + result.Should().HaveCount(20); + result.Should().OnlyContain(s => s.Time > DateTime.Now.AddDays(-30)); } } }