mirror of https://github.com/lidarr/Lidarr
ImdbId and Title Slug are now nullable
This commit is contained in:
parent
d89d9e67c2
commit
1e878a88fd
|
@ -97,10 +97,8 @@ namespace NzbDrone.Core.Test.Datastore.SQLiteMigrationHelperTests
|
|||
var columns = _subject.GetColumns("QualitySizes");
|
||||
var indexes = _subject.GetIndexes("QualitySizes");
|
||||
|
||||
|
||||
_subject.CreateTable("QualityB", columns.Values, indexes);
|
||||
|
||||
|
||||
var newIndexes = _subject.GetIndexes("QualityB");
|
||||
|
||||
newIndexes.Should().HaveSameCount(indexes);
|
||||
|
@ -122,6 +120,5 @@ namespace NzbDrone.Core.Test.Datastore.SQLiteMigrationHelperTests
|
|||
newColumns.Values.Should().HaveSameCount(columns.Values);
|
||||
newIndexes.Should().Contain(i=>i.Column == "AirTime");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,258 +0,0 @@
|
|||
/*
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test
|
||||
{
|
||||
[TestFixture]
|
||||
|
||||
public class EpisodeParseResultTest : CoreTest
|
||||
{
|
||||
[Test]
|
||||
public void tostring_single_season_episode()
|
||||
{
|
||||
var parseResult = new RemoteEpisode();
|
||||
parseResult.SeriesTitle = "My Series";
|
||||
parseResult.SeasonNumber = 12;
|
||||
parseResult.EpisodeNumbers = new List<int> { 3 };
|
||||
parseResult.FullSeason = false;
|
||||
parseResult.AirDate = null;
|
||||
parseResult.Quality = new QualityModel(Quality.HDTV720p, false);
|
||||
|
||||
|
||||
parseResult.ToString().Should().Be("My Series - S12E03 HDTV-720p");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void tostring_single_season_episode_proper()
|
||||
{
|
||||
var parseResult = new RemoteEpisode();
|
||||
parseResult.SeriesTitle = "My Series";
|
||||
parseResult.SeasonNumber = 12;
|
||||
parseResult.EpisodeNumbers = new List<int> { 3 };
|
||||
parseResult.FullSeason = false;
|
||||
parseResult.AirDate = null;
|
||||
parseResult.Quality = new QualityModel(Quality.HDTV720p, true);
|
||||
|
||||
|
||||
parseResult.ToString().Should().Be("My Series - S12E03 HDTV-720p [proper]");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void tostring_multi_season_episode()
|
||||
{
|
||||
var parseResult = new RemoteEpisode();
|
||||
parseResult.SeriesTitle = "My Series";
|
||||
parseResult.SeasonNumber = 12;
|
||||
parseResult.EpisodeNumbers = new List<int> { 3, 4, 5 };
|
||||
parseResult.FullSeason = false;
|
||||
parseResult.AirDate = null;
|
||||
parseResult.Quality = new QualityModel(Quality.HDTV720p, false);
|
||||
|
||||
|
||||
parseResult.ToString().Should().Be("My Series - S12E03-04-05 HDTV-720p");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void tostring_multi_season_episode_proper()
|
||||
{
|
||||
var parseResult = new RemoteEpisode();
|
||||
parseResult.SeriesTitle = "My Series";
|
||||
parseResult.SeasonNumber = 12;
|
||||
parseResult.EpisodeNumbers = new List<int> { 3, 4, 5 };
|
||||
parseResult.FullSeason = false;
|
||||
parseResult.AirDate = null;
|
||||
parseResult.Quality = new QualityModel(Quality.HDTV720p, true);
|
||||
|
||||
|
||||
parseResult.ToString().Should().Be("My Series - S12E03-04-05 HDTV-720p [proper]");
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void tostring_full_season()
|
||||
{
|
||||
var parseResult = new RemoteEpisode();
|
||||
parseResult.SeriesTitle = "My Series";
|
||||
parseResult.SeasonNumber = 12;
|
||||
parseResult.FullSeason = true;
|
||||
parseResult.AirDate = null;
|
||||
parseResult.Quality = new QualityModel(Quality.HDTV720p, false);
|
||||
|
||||
|
||||
parseResult.ToString().Should().Be("My Series - Season 12 HDTV-720p");
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void tostring_full_season_proper()
|
||||
{
|
||||
var parseResult = new RemoteEpisode();
|
||||
parseResult.SeriesTitle = "My Series";
|
||||
parseResult.SeasonNumber = 12;
|
||||
parseResult.FullSeason = true;
|
||||
parseResult.AirDate = null;
|
||||
parseResult.Quality = new QualityModel(Quality.HDTV720p, true);
|
||||
|
||||
|
||||
parseResult.ToString().Should().Be("My Series - Season 12 HDTV-720p [proper]");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void tostring_daily_show()
|
||||
{
|
||||
var parseResult = new RemoteEpisode();
|
||||
parseResult.SeriesTitle = "My Series";
|
||||
parseResult.SeasonNumber = 12;
|
||||
parseResult.FullSeason = true;
|
||||
parseResult.AirDate = new DateTime(2010, 12, 30);
|
||||
parseResult.Quality = new QualityModel(Quality.HDTV720p, false);
|
||||
|
||||
|
||||
parseResult.ToString().Should().Be("My Series - 2010-12-30 HDTV-720p");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void tostring_daily_show_proper()
|
||||
{
|
||||
var parseResult = new RemoteEpisode();
|
||||
parseResult.SeriesTitle = "My Series";
|
||||
parseResult.SeasonNumber = 12;
|
||||
parseResult.FullSeason = true;
|
||||
parseResult.AirDate = new DateTime(2010, 12, 30);
|
||||
parseResult.Quality = new QualityModel(Quality.HDTV720p, true);
|
||||
|
||||
|
||||
parseResult.ToString().Should().Be("My Series - 2010-12-30 HDTV-720p [proper]");
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static readonly object[] SabNamingCases =
|
||||
{
|
||||
new object[] { 1, new[] { 2 }, "My Episode Title", Quality.DVD, false, "My Series Name - 1x02 - My Episode Title [DVD]" },
|
||||
new object[] { 1, new[] { 2 }, "My Episode Title", Quality.DVD, true, "My Series Name - 1x02 - My Episode Title [DVD] [Proper]" },
|
||||
new object[] { 1, new[] { 2 }, "", Quality.DVD, true, "My Series Name - 1x02 - [DVD] [Proper]" },
|
||||
new object[] { 1, new[] { 2, 4 }, "My Episode Title", Quality.HDTV720p, false, "My Series Name - 1x02-1x04 - My Episode Title [HDTV-720p]" },
|
||||
new object[] { 1, new[] { 2, 4 }, "My Episode Title", Quality.HDTV720p, true, "My Series Name - 1x02-1x04 - My Episode Title [HDTV-720p] [Proper]" },
|
||||
new object[] { 1, new[] { 2, 4 }, "", Quality.HDTV720p, true, "My Series Name - 1x02-1x04 - [HDTV-720p] [Proper]" },
|
||||
};
|
||||
|
||||
|
||||
[Test, TestCaseSource("SabNamingCases")]
|
||||
public void create_proper_sab_titles(int seasons, int[] episodes, string title, Quality quality, bool proper, string expected)
|
||||
{
|
||||
var series = Builder<Series>.CreateNew()
|
||||
.With(c => c.Title = "My Series Name")
|
||||
.Build();
|
||||
|
||||
var fakeEpisodes = new List<Episode>();
|
||||
|
||||
foreach (var episode in episodes)
|
||||
fakeEpisodes.Add(Builder<Episode>
|
||||
.CreateNew()
|
||||
.With(e => e.EpisodeNumber = episode)
|
||||
.With(e => e.Title = title)
|
||||
.Build());
|
||||
|
||||
var parsResult = new RemoteEpisode()
|
||||
{
|
||||
AirDate = DateTime.Now,
|
||||
EpisodeNumbers = episodes.ToList(),
|
||||
Quality = new QualityModel(quality, proper),
|
||||
SeasonNumber = seasons,
|
||||
Series = series,
|
||||
EpisodeTitle = title,
|
||||
Episodes = fakeEpisodes
|
||||
};
|
||||
|
||||
parsResult.GetDownloadTitle().Should().Be(expected);
|
||||
}
|
||||
|
||||
[TestCase(true, Result = "My Series Name - Season 1 [Bluray720p] [Proper]")]
|
||||
[TestCase(false, Result = "My Series Name - Season 1 [Bluray720p]")]
|
||||
public string create_proper_sab_season_title(bool proper)
|
||||
{
|
||||
var series = Builder<Series>.CreateNew()
|
||||
.With(c => c.Title = "My Series Name")
|
||||
.Build();
|
||||
|
||||
var parsResult = new RemoteEpisode()
|
||||
{
|
||||
AirDate = DateTime.Now,
|
||||
Quality = new QualityModel(Quality.Bluray720p, proper),
|
||||
SeasonNumber = 1,
|
||||
Series = series,
|
||||
EpisodeTitle = "My Episode Title",
|
||||
FullSeason = true
|
||||
};
|
||||
|
||||
return parsResult.GetDownloadTitle();
|
||||
}
|
||||
|
||||
[TestCase(true, Result = "My Series Name - 2011-12-01 - My Episode Title [Bluray720p] [Proper]")]
|
||||
[TestCase(false, Result = "My Series Name - 2011-12-01 - My Episode Title [Bluray720p]")]
|
||||
public string create_proper_sab_daily_titles(bool proper)
|
||||
{
|
||||
var series = Builder<Series>.CreateNew()
|
||||
.With(c => c.SeriesType = SeriesTypes.Daily)
|
||||
.With(c => c.Title = "My Series Name")
|
||||
.Build();
|
||||
|
||||
var episode = Builder<Episode>.CreateNew()
|
||||
.With(e => e.Title = "My Episode Title")
|
||||
.Build();
|
||||
|
||||
var parsResult = new RemoteEpisode
|
||||
{
|
||||
AirDate = new DateTime(2011, 12, 1),
|
||||
Quality = new QualityModel(Quality.Bluray720p, proper),
|
||||
Series = series,
|
||||
EpisodeTitle = "My Episode Title",
|
||||
Episodes = new List<Episode> { episode }
|
||||
};
|
||||
|
||||
return parsResult.GetDownloadTitle();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_repeat_the_same_episode_title()
|
||||
{
|
||||
var series = Builder<Series>.CreateNew()
|
||||
.With(c => c.Title = "My Series Name")
|
||||
.Build();
|
||||
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
|
||||
.All()
|
||||
.With(e => e.SeasonNumber = 5)
|
||||
.TheFirst(1)
|
||||
.With(e => e.Title = "My Episode Title (1)")
|
||||
.TheLast(1)
|
||||
.With(e => e.Title = "My Episode Title (2)")
|
||||
.Build();
|
||||
|
||||
var parsResult = new RemoteEpisode
|
||||
{
|
||||
AirDate = DateTime.Now,
|
||||
EpisodeNumbers = new List<int> { 10, 11 },
|
||||
Quality = new QualityModel(Quality.HDTV720p, false),
|
||||
SeasonNumber = 35,
|
||||
Series = series,
|
||||
Episodes = fakeEpisodes
|
||||
};
|
||||
|
||||
parsResult.GetDownloadTitle().Should().Be("My Series Name - 5x01-5x02 - My Episode Title [HDTV-720p]");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
|
@ -185,7 +185,6 @@
|
|||
<Compile Include="Qualities\QualityProfileRepositoryFixture.cs" />
|
||||
<Compile Include="RootFolderTests\FreeSpaceOnDrivesFixture.cs" />
|
||||
<Compile Include="Qualities\QualityFixture.cs" />
|
||||
<Compile Include="EpisodeParseResultTest.cs" />
|
||||
<Compile Include="ParserTests\QualityParserFixture.cs" />
|
||||
<Compile Include="Configuration\ConfigCachingFixture.cs" />
|
||||
<Compile Include="ProviderTests\DiskScanProviderTests\GetVideoFilesFixture.cs" />
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
using FluentMigrator;
|
||||
using NzbDrone.Core.Datastore.Migration.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migration
|
||||
{
|
||||
[Migration(34)]
|
||||
public class remove_series_contraints : NzbDroneMigrationBase
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
SqLiteAlter.Nullify("Series", new[] { "ImdbId", "TitleSlug" });
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migration.Framework
|
||||
|
@ -7,6 +8,7 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
|
|||
{
|
||||
void DropColumns(string tableName, IEnumerable<string> columns);
|
||||
void AddIndexes(string tableName, params SQLiteIndex[] indexes);
|
||||
void Nullify(string tableName, IEnumerable<string> columns);
|
||||
}
|
||||
|
||||
public class SQLiteAlter : ISQLiteAlter
|
||||
|
@ -50,6 +52,44 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
|
|||
}
|
||||
}
|
||||
|
||||
public void Nullify(string tableName, IEnumerable<string> columns)
|
||||
{
|
||||
using (var transaction = _sqLiteMigrationHelper.BeginTransaction())
|
||||
{
|
||||
var originalColumns = _sqLiteMigrationHelper.GetColumns(tableName);
|
||||
var originalIndexes = _sqLiteMigrationHelper.GetIndexes(tableName);
|
||||
|
||||
var newColumns = originalColumns.Select(c =>
|
||||
{
|
||||
if (!columns.Contains(c.Key))
|
||||
{
|
||||
return c.Value;
|
||||
}
|
||||
|
||||
if (!c.Value.Schema.Contains("NOT NULL") && c.Value.Schema.Contains("NULL"))
|
||||
{
|
||||
return c.Value;
|
||||
}
|
||||
|
||||
if (c.Value.Schema.Contains("NOT NULL"))
|
||||
{
|
||||
c.Value.Schema = c.Value.Schema.Replace("NOT NULL", "NULL");
|
||||
return c.Value;
|
||||
}
|
||||
|
||||
c.Value.Schema += " NULL";
|
||||
|
||||
return c.Value;
|
||||
}).ToList();
|
||||
|
||||
var newIndexes = originalIndexes;
|
||||
|
||||
CreateTable(tableName, newColumns, newIndexes);
|
||||
|
||||
transaction.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateTable(string tableName, List<SQLiteColumn> newColumns, IEnumerable<SQLiteIndex> newIndexes)
|
||||
{
|
||||
var tempTableName = tableName + "_temp";
|
||||
|
|
|
@ -189,6 +189,7 @@
|
|||
<Compile Include="Datastore\Migration\030_add_season_folder_format_to_naming_config.cs" />
|
||||
<Compile Include="Datastore\Migration\032_set_default_release_group.cs" />
|
||||
<Compile Include="Datastore\Migration\033_add_api_key_to_pushover.cs" />
|
||||
<Compile Include="Datastore\Migration\034_remove_series_contraints.cs" />
|
||||
<Compile Include="Datastore\Migration\Framework\MigrationContext.cs" />
|
||||
<Compile Include="Datastore\Migration\Framework\MigrationController.cs" />
|
||||
<Compile Include="Datastore\Migration\Framework\MigrationExtension.cs" />
|
||||
|
|
Loading…
Reference in New Issue