Cleaned up 2160p changes and added migration and tests.

Also reserved the quality ids for WEBRip etc.
pull/2/head
Taloth Saldono 9 years ago
parent 94323f79e7
commit f25f5abced

@ -0,0 +1,35 @@
using System.Linq;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Datastore.Migration;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.Datastore.Migration
{
[TestFixture]
public class add_ultrahd_quality_in_profilesFixture : MigrationTest<add_ultrahd_quality_in_profiles>
{
[Test]
public void should_add_ultrahd_to_old_profile()
{
var db = WithMigrationTestDb(c =>
{
c.Insert.IntoTable("Profiles").Row(new
{
Id = 0,
Name = "SDTV",
Cutoff = 1,
Items = "[ { \"quality\": 1, \"allowed\": true } ]",
Language = 1
});
});
var profiles = db.Query<Profile70>("SELECT Items FROM Profiles LIMIT 1");
var items = profiles.First().Items;
items.Should().HaveCount(4);
items.Select(v => v.Quality).Should().BeEquivalentTo(1, 16, 18, 19);
items.Select(v => v.Allowed).Should().BeEquivalentTo(true, false, false, false);
}
}
}

@ -119,6 +119,7 @@
<Compile Include="Datastore\DatabaseRelationshipFixture.cs" /> <Compile Include="Datastore\DatabaseRelationshipFixture.cs" />
<Compile Include="Datastore\MappingExtentionFixture.cs" /> <Compile Include="Datastore\MappingExtentionFixture.cs" />
<Compile Include="Datastore\MarrDataLazyLoadingFixture.cs" /> <Compile Include="Datastore\MarrDataLazyLoadingFixture.cs" />
<Compile Include="Datastore\Migration\101_add_ultrahd_quality_in_profilesFixture.cs" />
<Compile Include="Datastore\Migration\071_unknown_quality_in_profileFixture.cs" /> <Compile Include="Datastore\Migration\071_unknown_quality_in_profileFixture.cs" />
<Compile Include="Datastore\Migration\072_history_downloadIdFixture.cs" /> <Compile Include="Datastore\Migration\072_history_downloadIdFixture.cs" />
<Compile Include="Datastore\Migration\070_delay_profileFixture.cs" /> <Compile Include="Datastore\Migration\070_delay_profileFixture.cs" />

@ -24,9 +24,9 @@ namespace NzbDrone.Core.Test.Qualities
new object[] {8, Quality.WEBDL480p}, new object[] {8, Quality.WEBDL480p},
new object[] {9, Quality.HDTV1080p}, new object[] {9, Quality.HDTV1080p},
new object[] {10, Quality.RAWHD}, new object[] {10, Quality.RAWHD},
new object[] {12, Quality.HDTV2160p}, new object[] {16, Quality.HDTV2160p},
new object[] {13, Quality.WEBDL2160p}, new object[] {18, Quality.WEBDL2160p},
new object[] {14, Quality.Bluray2160p}, new object[] {19, Quality.Bluray2160p},
}; };
public static object[] ToIntCases = public static object[] ToIntCases =
@ -42,9 +42,9 @@ namespace NzbDrone.Core.Test.Qualities
new object[] {Quality.WEBDL480p, 8}, new object[] {Quality.WEBDL480p, 8},
new object[] {Quality.HDTV1080p, 9}, new object[] {Quality.HDTV1080p, 9},
new object[] {Quality.RAWHD, 10}, new object[] {Quality.RAWHD, 10},
new object[] {Quality.HDTV2160p, 12}, new object[] {Quality.HDTV2160p, 16},
new object[] {Quality.WEBDL2160p, 13}, new object[] {Quality.WEBDL2160p, 18},
new object[] {Quality.Bluray2160p, 14}, new object[] {Quality.Bluray2160p, 19},
}; };
[Test, TestCaseSource("FromIntCases")] [Test, TestCaseSource("FromIntCases")]

@ -0,0 +1,35 @@
using System.Collections.Generic;
using System.Data;
using System.Linq;
using FluentMigrator;
using NzbDrone.Common.Serializer;
using NzbDrone.Core.Datastore.Migration.Framework;
namespace NzbDrone.Core.Datastore.Migration
{
[Migration(101)]
public class add_ultrahd_quality_in_profiles : NzbDroneMigrationBase
{
protected override void MainDbUpgrade()
{
Execute.WithConnection(ConvertProfile);
}
private void ConvertProfile(IDbConnection conn, IDbTransaction tran)
{
var updater = new ProfileUpdater70(conn, tran);
updater.AppendQuality(16); // HDTV2160p
updater.AppendQuality(18); // WEBDL2160p
updater.AppendQuality(19); // Bluray2160p
updater.Commit();
// WEBRip migrations.
//updater.SplitQualityAppend(1, 11); // HDTV480p after SDTV
//updater.SplitQualityPrepend(8, 12); // WEBRip480p before WEBDL480p
//updater.SplitQualityAppend(2, 13); // Bluray480p after DVD
//updater.SplitQualityPrepend(5, 14); // WEBRip720p before WEBDL720p
//updater.SplitQualityPrepend(3, 15); // WEBRip1080p before WEBDL1080p
//updater.SplitQualityPrepend(18, 17); // WEBRip2160p before WEBDL2160p
}
}
}

@ -251,6 +251,7 @@
<Compile Include="Datastore\Migration\068_add_release_restrictions.cs" /> <Compile Include="Datastore\Migration\068_add_release_restrictions.cs" />
<Compile Include="Datastore\Migration\069_quality_proper.cs" /> <Compile Include="Datastore\Migration\069_quality_proper.cs" />
<Compile Include="Datastore\Migration\070_delay_profile.cs" /> <Compile Include="Datastore\Migration\070_delay_profile.cs" />
<Compile Include="Datastore\Migration\101_add_ultrahd_quality_in_profiles.cs" />
<Compile Include="Datastore\Migration\071_unknown_quality_in_profile.cs" /> <Compile Include="Datastore\Migration\071_unknown_quality_in_profile.cs" />
<Compile Include="Datastore\Migration\072_history_grabid.cs" /> <Compile Include="Datastore\Migration\072_history_grabid.cs" />
<Compile Include="Datastore\Migration\073_clear_ratings.cs" /> <Compile Include="Datastore\Migration\073_clear_ratings.cs" />

@ -94,8 +94,7 @@ namespace NzbDrone.Core.Profiles
Quality.WEBDL720p, Quality.WEBDL720p,
Quality.WEBDL1080p, Quality.WEBDL1080p,
Quality.Bluray720p, Quality.Bluray720p,
Quality.Bluray1080p, Quality.Bluray1080p);
Quality.WEBDL2160p);
AddDefaultProfile("SD", Quality.SDTV, AddDefaultProfile("SD", Quality.SDTV,
Quality.SDTV, Quality.SDTV,
@ -112,21 +111,18 @@ namespace NzbDrone.Core.Profiles
Quality.WEBDL1080p, Quality.WEBDL1080p,
Quality.Bluray1080p); Quality.Bluray1080p);
AddDefaultProfile("HD-2160p", Quality.HDTV2160p, AddDefaultProfile("Ultra-HD", Quality.HDTV2160p,
Quality.HDTV2160p, Quality.HDTV2160p,
Quality.WEBDL2160p, Quality.WEBDL2160p,
Quality.Bluray2160p); Quality.Bluray2160p);
AddDefaultProfile("HD - All", Quality.HDTV720p, AddDefaultProfile("HD - 720p/1080p", Quality.HDTV720p,
Quality.HDTV720p, Quality.HDTV720p,
Quality.HDTV1080p, Quality.HDTV1080p,
Quality.HDTV2160p,
Quality.WEBDL720p, Quality.WEBDL720p,
Quality.WEBDL1080p, Quality.WEBDL1080p,
Quality.WEBDL2160p,
Quality.Bluray720p, Quality.Bluray720p,
Quality.Bluray1080p, Quality.Bluray1080p);
Quality.Bluray2160p);
} }
} }
} }

@ -67,10 +67,15 @@ namespace NzbDrone.Core.Qualities
public static Quality HDTV1080p { get { return new Quality(9, "HDTV-1080p"); } } public static Quality HDTV1080p { get { return new Quality(9, "HDTV-1080p"); } }
public static Quality RAWHD { get { return new Quality(10, "Raw-HD"); } } public static Quality RAWHD { get { return new Quality(10, "Raw-HD"); } }
//public static Quality HDTV480p { get { return new Quality(11, "HDTV-480p"); } } //public static Quality HDTV480p { get { return new Quality(11, "HDTV-480p"); } }
public static Quality HDTV2160p { get { return new Quality(12, "HDTV-2160p"); } } //public static Quality WEBRip480p { get { return new Quality(12, "WEBRip-480p"); } }
public static Quality WEBDL2160p { get { return new Quality(13, "WEBDL-2160p"); } } //public static Quality Bluray480p { get { return new Quality(13, "Bluray-480p"); } }
public static Quality Bluray2160p { get { return new Quality(14, "Bluray-2160p"); } } //public static Quality WEBRip720p { get { return new Quality(14, "WEBRip-720p"); } }
//public static Quality WEBRip1080p { get { return new Quality(15, "WEBRip-1080p"); } }
public static Quality HDTV2160p { get { return new Quality(16, "HDTV-2160p"); } }
//public static Quality WEBRip2160p { get { return new Quality(17, "WEBRip-1080p"); } }
public static Quality WEBDL2160p { get { return new Quality(18, "WEBDL-2160p"); } }
public static Quality Bluray2160p { get { return new Quality(19, "Bluray-2160p"); } }
public static List<Quality> All public static List<Quality> All
{ {
get get
@ -112,9 +117,9 @@ namespace NzbDrone.Core.Qualities
new QualityDefinition(Quality.Bluray720p) { Weight = 9, MinSize = 0, MaxSize = 100 }, new QualityDefinition(Quality.Bluray720p) { Weight = 9, MinSize = 0, MaxSize = 100 },
new QualityDefinition(Quality.WEBDL1080p) { Weight = 10, MinSize = 0, MaxSize = 100 }, new QualityDefinition(Quality.WEBDL1080p) { Weight = 10, MinSize = 0, MaxSize = 100 },
new QualityDefinition(Quality.Bluray1080p) { Weight = 11, MinSize = 0, MaxSize = 100 }, new QualityDefinition(Quality.Bluray1080p) { Weight = 11, MinSize = 0, MaxSize = 100 },
new QualityDefinition(Quality.HDTV2160p) { Weight = 12, MinSize = 0, MaxSize = 100 }, new QualityDefinition(Quality.HDTV2160p) { Weight = 12, MinSize = 0, MaxSize = null },
new QualityDefinition(Quality.WEBDL2160p) { Weight = 13, MinSize = 0, MaxSize = 100 }, new QualityDefinition(Quality.WEBDL2160p) { Weight = 13, MinSize = 0, MaxSize = null },
new QualityDefinition(Quality.Bluray2160p) { Weight = 14, MinSize = 0, MaxSize = 100 }, new QualityDefinition(Quality.Bluray2160p) { Weight = 14, MinSize = 0, MaxSize = null },
}; };
} }
} }

Loading…
Cancel
Save