diff --git a/src/NzbDrone.Core/Datastore/Migration/116_update_movie_sorttitle_again.cs b/src/NzbDrone.Core/Datastore/Migration/116_update_movie_sorttitle_again.cs new file mode 100644 index 000000000..45666b1c2 --- /dev/null +++ b/src/NzbDrone.Core/Datastore/Migration/116_update_movie_sorttitle_again.cs @@ -0,0 +1,44 @@ +using System.Data; +using FluentMigrator; +using NzbDrone.Core.Datastore.Migration.Framework; + +namespace NzbDrone.Core.Datastore.Migration +{ + [Migration(116)] + public class update_movie_sorttitle_again : NzbDroneMigrationBase + { + protected override void MainDbUpgrade() + { + Execute.WithConnection(SetSortTitles); + } + + private void SetSortTitles(IDbConnection conn, IDbTransaction tran) + { + using (IDbCommand getSeriesCmd = conn.CreateCommand()) + { + getSeriesCmd.Transaction = tran; + getSeriesCmd.CommandText = @"SELECT Id, Title FROM Movies"; + using (IDataReader seriesReader = getSeriesCmd.ExecuteReader()) + { + while (seriesReader.Read()) + { + var id = seriesReader.GetInt32(0); + var title = seriesReader.GetString(1); + + var sortTitle = Parser.Parser.NormalizeTitle(title).ToLower(); + + using (IDbCommand updateCmd = conn.CreateCommand()) + { + updateCmd.Transaction = tran; + updateCmd.CommandText = "UPDATE Movies SET SortTitle = ? WHERE Id = ?"; + updateCmd.AddParameter(sortTitle); + updateCmd.AddParameter(id); + + updateCmd.ExecuteNonQuery(); + } + } + } + } + } + } +} diff --git a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs index 2d8248638..318dccbd4 100644 --- a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs +++ b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs @@ -90,6 +90,7 @@ public Movie GetMovieInfo(int TmdbId) movie.Title = resource.title; movie.TitleSlug = movie.Title.ToLower().Replace(" ", "-"); movie.CleanTitle = Parser.Parser.CleanSeriesTitle(movie.Title); + movie.SortTitle = Parser.Parser.NormalizeTitle(movie.Title); movie.Overview = resource.overview; movie.Website = resource.homepage; if (resource.release_date.IsNotNullOrWhiteSpace()) diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index 9dfb29ec2..a0221be03 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -183,6 +183,7 @@ + diff --git a/src/UI/Movies/Index/MoviesIndexLayout.js b/src/UI/Movies/Index/MoviesIndexLayout.js index a4db4c892..ff71eab7f 100644 --- a/src/UI/Movies/Index/MoviesIndexLayout.js +++ b/src/UI/Movies/Index/MoviesIndexLayout.js @@ -139,7 +139,7 @@ module.exports = Marionette.Layout.extend({ items : [ { title : 'Title', - name : 'title' + name : 'sortTitle' }, { title : 'Quality',