Added Series SortTitle Migration. (Left a slot for anime)

pull/84/head
Taloth Saldono 11 years ago
parent a75ce9ab87
commit fd5e8a5166

@ -15,6 +15,7 @@ namespace NzbDrone.Api.Series
//View Only
public String Title { get; set; }
public String SortTitle { get; set; }
public List<String> AlternativeTitles { get; set; }
public Int32 SeasonCount

@ -40,6 +40,7 @@ namespace NzbDrone.Core.Test.MetadataSourceTests
[TestCase(75978)]
[TestCase(83462)]
[TestCase(266189)]
public void should_be_able_to_get_series_detail(int tvdbId)
{
var details = Subject.GetSeriesInfo(tvdbId);
@ -61,6 +62,7 @@ namespace NzbDrone.Core.Test.MetadataSourceTests
series.Should().NotBeNull();
series.Title.Should().NotBeBlank();
series.CleanTitle.Should().Be(Parser.Parser.CleanSeriesTitle(series.Title));
series.SortTitle.Should().Be(Parser.Parser.NormalizeEpisodeTitle(series.Title));
series.Overview.Should().NotBeBlank();
series.AirTime.Should().NotBeBlank();
series.FirstAired.Should().HaveValue();

@ -0,0 +1,53 @@
using System;
using System.IO;
using System.Data;
using System.Linq;
using System.Collections.Generic;
using FluentMigrator;
using Newtonsoft.Json;
using NzbDrone.Common;
using NzbDrone.Common.Serializer;
using NzbDrone.Core.Datastore.Migration.Framework;
namespace NzbDrone.Core.Datastore.Migration
{
[Migration(53)]
public class add_series_sorttitle : NzbDroneMigrationBase
{
protected override void MainDbUpgrade()
{
Create.Column("SortTitle").OnTable("Series").AsString().Nullable();
Execute.WithConnection(SetSortTitles);
}
private void SetSortTitles(IDbConnection conn, IDbTransaction tran)
{
using (IDbCommand getSeriesCmd = conn.CreateCommand())
{
getSeriesCmd.Transaction = tran;
getSeriesCmd.CommandText = @"SELECT Id, Title FROM Series";
using (IDataReader seriesReader = getSeriesCmd.ExecuteReader())
{
while (seriesReader.Read())
{
var id = seriesReader.GetInt32(0);
var title = seriesReader.GetString(1);
var sortTitle = Parser.Parser.NormalizeEpisodeTitle(title).ToLower();
using (IDbCommand updateCmd = conn.CreateCommand())
{
updateCmd.Transaction = tran;
updateCmd.CommandText = "UPDATE Series SET SortTitle = ? WHERE Id = ?";
updateCmd.AddParameter(sortTitle);
updateCmd.AddParameter(id);
updateCmd.ExecuteNonQuery();
}
}
}
}
}
}
}

@ -105,6 +105,7 @@ namespace NzbDrone.Core.MetadataSource
series.ImdbId = show.imdb_id;
series.Title = show.title;
series.CleanTitle = Parser.Parser.CleanSeriesTitle(show.title);
series.SortTitle = Parser.Parser.NormalizeEpisodeTitle(show.title).ToLower();
series.Year = GetYear(show.year, show.first_aired);
series.FirstAired = FromIso(show.first_aired_iso);
series.Overview = show.overview;

@ -198,6 +198,7 @@
<Compile Include="Datastore\Migration\049_fix_dognzb_url.cs" />
<Compile Include="Datastore\Migration\050_add_hash_to_metadata_files.cs" />
<Compile Include="Datastore\Migration\051_download_client_import.cs" />
<Compile Include="Datastore\Migration\053_add_series_sorttitle.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationContext.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationController.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationExtension.cs" />

@ -58,6 +58,7 @@ namespace NzbDrone.Core.Tv
series.Overview = seriesInfo.Overview;
series.Status = seriesInfo.Status;
series.CleanTitle = seriesInfo.CleanTitle;
series.SortTitle = seriesInfo.SortTitle;
series.LastInfoSync = DateTime.UtcNow;
series.Runtime = seriesInfo.Runtime;
series.Images = seriesInfo.Images;

@ -22,6 +22,7 @@ namespace NzbDrone.Core.Tv
public string ImdbId { get; set; }
public string Title { get; set; }
public string CleanTitle { get; set; }
public string SortTitle { get; set; }
public SeriesStatusType Status { get; set; }
public string Overview { get; set; }
public String AirTime { get; set; }

@ -78,6 +78,7 @@ namespace NzbDrone.Core.Tv
newSeries.Monitored = true;
newSeries.CleanTitle = Parser.Parser.CleanSeriesTitle(newSeries.Title);
newSeries.SortTitle = Parser.Parser.NormalizeEpisodeTitle(newSeries.Title).ToLower();
_seriesRepository.Insert(newSeries);
_eventAggregator.PublishEvent(new SeriesAddedEvent(GetSeries(newSeries.Id)));

Loading…
Cancel
Save