From 4c8b1d960483f2845d6879b01abdecec207200cb Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sun, 5 Jun 2011 12:15:46 -0700 Subject: [PATCH 1/4] Fixed bug in history check. --- NzbDrone.Core.Test/HistoryProviderTest.cs | 4 +++- NzbDrone.Core/Providers/HistoryProvider.cs | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/NzbDrone.Core.Test/HistoryProviderTest.cs b/NzbDrone.Core.Test/HistoryProviderTest.cs index 256e926ad..18c6df726 100644 --- a/NzbDrone.Core.Test/HistoryProviderTest.cs +++ b/NzbDrone.Core.Test/HistoryProviderTest.cs @@ -79,7 +79,8 @@ namespace NzbDrone.Core.Test var repo = MockLib.GetEmptyRepository(); - var history = Builder.CreateNew().Build(); + var history = Builder.CreateNew() + .With(h => h.Quality = QualityTypes.Bluray720p).Build(); repo.Add(history); mocker.SetConstant(repo); @@ -88,6 +89,7 @@ namespace NzbDrone.Core.Test //Assert Assert.IsNotNull(result); + result.QualityType.Should().Be(QualityTypes.Bluray720p); } [Test] diff --git a/NzbDrone.Core/Providers/HistoryProvider.cs b/NzbDrone.Core/Providers/HistoryProvider.cs index 189de8d84..c1d2a642e 100644 --- a/NzbDrone.Core/Providers/HistoryProvider.cs +++ b/NzbDrone.Core/Providers/HistoryProvider.cs @@ -49,8 +49,8 @@ namespace NzbDrone.Core.Providers public virtual Quality GetBestQualityInHistory(long episodeId) { - var history = AllItems().Where(c => c.EpisodeId == episodeId).Select(d => new Quality() { QualityType = d.Quality, Proper = d.IsProper }).ToList(); - history.Sort(); + var history = AllItems().Where(c => c.EpisodeId == episodeId).ToList().Select(d => new Quality(d.Quality, d.IsProper)); + history.OrderBy(q => q); return history.FirstOrDefault(); } From fa5b6bf9cc7d4fe852058045bfc2bca4bbf5d8f1 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sun, 5 Jun 2011 12:42:53 -0700 Subject: [PATCH 2/4] Fixed history order bug. --- NzbDrone.Core/Providers/HistoryProvider.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NzbDrone.Core/Providers/HistoryProvider.cs b/NzbDrone.Core/Providers/HistoryProvider.cs index c1d2a642e..b639eebe2 100644 --- a/NzbDrone.Core/Providers/HistoryProvider.cs +++ b/NzbDrone.Core/Providers/HistoryProvider.cs @@ -49,8 +49,8 @@ namespace NzbDrone.Core.Providers public virtual Quality GetBestQualityInHistory(long episodeId) { - var history = AllItems().Where(c => c.EpisodeId == episodeId).ToList().Select(d => new Quality(d.Quality, d.IsProper)); - history.OrderBy(q => q); + var history = AllItems().Where(c => c.EpisodeId == episodeId).Select(d => new Quality(d.Quality, d.IsProper)).OrderBy(c => c); + return history.FirstOrDefault(); } From 120a75ed8ec8dcff4cffb8c79eb54a11b7fb9afe Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sun, 5 Jun 2011 12:55:46 -0700 Subject: [PATCH 3/4] Fixed history again. --- NzbDrone.Core/Providers/HistoryProvider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NzbDrone.Core/Providers/HistoryProvider.cs b/NzbDrone.Core/Providers/HistoryProvider.cs index b639eebe2..1074f1740 100644 --- a/NzbDrone.Core/Providers/HistoryProvider.cs +++ b/NzbDrone.Core/Providers/HistoryProvider.cs @@ -49,7 +49,7 @@ namespace NzbDrone.Core.Providers public virtual Quality GetBestQualityInHistory(long episodeId) { - var history = AllItems().Where(c => c.EpisodeId == episodeId).Select(d => new Quality(d.Quality, d.IsProper)).OrderBy(c => c); + var history = AllItems().Where(c => c.EpisodeId == episodeId).ToList().Select(d => new Quality(d.Quality, d.IsProper)).OrderBy(c => c); return history.FirstOrDefault(); } From 4812cb461132129585343f5686ca5186d942c23d Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sun, 5 Jun 2011 13:01:28 -0700 Subject: [PATCH 4/4] Increased sqlite cache size to 30mb --- NzbDrone.Core/Datastore/Connection.cs | 2 +- NzbDrone.Core/Datastore/SqliteProvider.cs | 28 +++++++++++++++++++++++ NzbDrone.Core/NzbDrone.Core.csproj | 1 + 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 NzbDrone.Core/Datastore/SqliteProvider.cs diff --git a/NzbDrone.Core/Datastore/Connection.cs b/NzbDrone.Core/Datastore/Connection.cs index b717abd0f..9e2c836e5 100644 --- a/NzbDrone.Core/Datastore/Connection.cs +++ b/NzbDrone.Core/Datastore/Connection.cs @@ -20,7 +20,7 @@ namespace NzbDrone.Core.Datastore public static string GetConnectionString(string path) { - return String.Format("Data Source={0};Version=3;", path); + return String.Format("Data Source={0};Version=3;Cache Size=30000;", path); } public static String MainConnectionString diff --git a/NzbDrone.Core/Datastore/SqliteProvider.cs b/NzbDrone.Core/Datastore/SqliteProvider.cs new file mode 100644 index 000000000..b4b2e278c --- /dev/null +++ b/NzbDrone.Core/Datastore/SqliteProvider.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Migrator.Framework; +using Migrator.Providers.SQLite; + +namespace NzbDrone.Core.Datastore +{ + class SqliteProvider + { + private readonly ITransformationProvider _dataBase; + + public SqliteProvider(string connectionString) + { + _dataBase = new SQLiteTransformationProvider(new SQLiteDialect(), connectionString); + } + + + public int GetPageSize() + { + return Convert.ToInt32(_dataBase.ExecuteScalar("PRAGMA cache_size")); + } + + + + } +} diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index fb3009a98..69eff6d93 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -164,6 +164,7 @@ +