From c21a971b98c99a006642dd762422edcf876e8aa6 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 15 May 2016 13:24:59 -0400 Subject: [PATCH 1/9] update sync db indexes --- MediaBrowser.Server.Implementations/Sync/SyncRepository.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs b/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs index 6d31663b9..739d1ab6e 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs @@ -49,9 +49,11 @@ namespace MediaBrowser.Server.Implementations.Sync "create table if not exists SyncJobs (Id GUID PRIMARY KEY, TargetId TEXT NOT NULL, Name TEXT NOT NULL, Profile TEXT, Quality TEXT, Bitrate INT, Status TEXT NOT NULL, Progress FLOAT, UserId TEXT NOT NULL, ItemIds TEXT NOT NULL, Category TEXT, ParentId TEXT, UnwatchedOnly BIT, ItemLimit INT, SyncNewContent BIT, DateCreated DateTime, DateLastModified DateTime, ItemCount int)", "create index if not exists idx_SyncJobs on SyncJobs(Id)", + "create index if not exists idx_SyncJobs1 on SyncJobs(TargetId)", "create table if not exists SyncJobItems (Id GUID PRIMARY KEY, ItemId TEXT, ItemName TEXT, MediaSourceId TEXT, JobId TEXT, TemporaryPath TEXT, OutputPath TEXT, Status TEXT, TargetId TEXT, DateCreated DateTime, Progress FLOAT, AdditionalFiles TEXT, MediaSource TEXT, IsMarkedForRemoval BIT, JobItemIndex INT, ItemDateModifiedTicks BIGINT)", - "create index if not exists idx_SyncJobItems on SyncJobs(Id)", + "create index if not exists idx_SyncJobItems1 on SyncJobItems(Id)", + "create index if not exists idx_SyncJobItems2 on SyncJobItems(TargetId)", //pragmas "pragma temp_store = memory", From 9ad551c77c262913d0645f2456e30ddcc5e30407 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 15 May 2016 14:52:36 -0400 Subject: [PATCH 2/9] update music tabs --- .../Persistence/SqliteItemRepository.cs | 38 ++++++++++++------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs index 8f7119b4a..e04c87917 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs @@ -1643,9 +1643,7 @@ namespace MediaBrowser.Server.Implementations.Persistence using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess | CommandBehavior.SingleResult)) { - //Logger.Debug("GetItemList query time: {0}ms. Query: {1}", - // Convert.ToInt32((DateTime.UtcNow - now).TotalMilliseconds), - // cmd.CommandText); + LogQueryTime("GetItemList", cmd, now); while (reader.Read()) { @@ -1659,6 +1657,26 @@ namespace MediaBrowser.Server.Implementations.Persistence } } + private void LogQueryTime(string methodName, IDbCommand cmd, DateTime startDate) + { + var elapsed = (DateTime.UtcNow - startDate).TotalMilliseconds; + + if (elapsed >= 500) + { + Logger.Debug("{2} query time (slow): {0}ms. Query: {1}", + Convert.ToInt32(elapsed), + cmd.CommandText, + methodName); + } + else + { + //Logger.Debug("{2} query time: {0}ms. Query: {1}", + // Convert.ToInt32(elapsed), + // cmd.CommandText, + // methodName); + } + } + public QueryResult GetItems(InternalItemsQuery query) { if (query == null) @@ -1728,9 +1746,7 @@ namespace MediaBrowser.Server.Implementations.Persistence using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess)) { - //Logger.Debug("GetItems query time: {0}ms. Query: {1}", - // Convert.ToInt32((DateTime.UtcNow - now).TotalMilliseconds), - // cmd.CommandText); + LogQueryTime("GetItems", cmd, now); while (reader.Read()) { @@ -1878,9 +1894,7 @@ namespace MediaBrowser.Server.Implementations.Persistence using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess | CommandBehavior.SingleResult)) { - //Logger.Debug("GetItemIdsList query time: {0}ms. Query: {1}", - // Convert.ToInt32((DateTime.UtcNow - now).TotalMilliseconds), - // cmd.CommandText); + LogQueryTime("GetItemIdsList", cmd, now); while (reader.Read()) { @@ -2036,9 +2050,7 @@ namespace MediaBrowser.Server.Implementations.Persistence using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess)) { - //Logger.Debug("GetItemIds query time: {0}ms. Query: {1}", - // Convert.ToInt32((DateTime.UtcNow - now).TotalMilliseconds), - // cmd.CommandText); + LogQueryTime("GetItemIds", cmd, now); while (reader.Read()) { @@ -2562,8 +2574,8 @@ namespace MediaBrowser.Server.Implementations.Persistence clause += " OR "; } clause += "Album=@AlbumName" + index; - index++; cmd.Parameters.Add(cmd, "@AlbumName" + index, DbType.String).Value = name; + index++; } clause += ")"; From abf9809a1d1b18cda1b1455a51b57689ee254f0d Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 15 May 2016 15:25:54 -0400 Subject: [PATCH 3/9] fix playlists empty with dlna --- .../Entities/InternalItemsQuery.cs | 5 +++ .../Entities/UserViewBuilder.cs | 33 +++++++++++-------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs index 5236b0a27..ae38f6143 100644 --- a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs +++ b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs @@ -181,6 +181,11 @@ namespace MediaBrowser.Controller.Entities public InternalItemsQuery(User user) : this() + { + SetUser(user); + } + + public void SetUser(User user) { if (user != null) { diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index ba496fa5c..caf160f02 100644 --- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs +++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs @@ -125,13 +125,13 @@ namespace MediaBrowser.Controller.Entities case CollectionType.HomeVideos: case CollectionType.Games: case CollectionType.MusicVideos: - { - if (query.Recursive) { - return GetResult(queryParent.GetRecursiveChildren(user, true), queryParent, query); + if (query.Recursive) + { + return GetResult(queryParent.GetRecursiveChildren(user, true), queryParent, query); + } + return GetResult(queryParent.GetChildren(user, true), queryParent, query); } - return GetResult(queryParent.GetChildren(user, true), queryParent, query); - } case CollectionType.Folders: return GetResult(user.RootFolder.GetChildren(user, true), queryParent, query); @@ -140,7 +140,7 @@ namespace MediaBrowser.Controller.Entities return await GetPlaylistsView(queryParent, user, query).ConfigureAwait(false); case CollectionType.BoxSets: - return await GetBoxsetView(queryParent, user, query).ConfigureAwait(false); + return GetBoxsetView(queryParent, user, query); case CollectionType.TvShows: return await GetTvView(queryParent, user, query).ConfigureAwait(false); @@ -206,7 +206,7 @@ namespace MediaBrowser.Controller.Entities return GetMusicLatest(queryParent, user, query); case SpecialFolder.MusicPlaylists: - return await GetMusicPlaylists(queryParent, user, query).ConfigureAwait(false); + return GetMusicPlaylists(queryParent, user, query); case SpecialFolder.MusicAlbums: return GetMusicAlbums(queryParent, user, query); @@ -353,12 +353,14 @@ namespace MediaBrowser.Controller.Entities return GetResult(artists, parent, query); } - private Task> GetMusicPlaylists(Folder parent, User user, InternalItemsQuery query) + private QueryResult GetMusicPlaylists(Folder parent, User user, InternalItemsQuery query) { - query.IncludeItemTypes = new[] { "Playlist" }; + query.ParentId = null; + query.IncludeItemTypes = new[] { typeof(Playlist).Name }; + query.SetUser(user); query.Recursive = true; - return parent.GetItems(query); + return _libraryManager.GetItemsResult(query); } private QueryResult GetMusicAlbums(Folder parent, User user, InternalItemsQuery query) @@ -559,11 +561,14 @@ namespace MediaBrowser.Controller.Entities return GetResult(_playlistManager.GetPlaylists(user.Id.ToString("N")), parent, query); } - private async Task> GetBoxsetView(Folder parent, User user, InternalItemsQuery query) + private QueryResult GetBoxsetView(Folder parent, User user, InternalItemsQuery query) { - var collections = _collectionManager.GetCollections(user); + query.ParentId = null; + query.IncludeItemTypes = new[] { typeof(BoxSet).Name }; + query.SetUser(user); + query.Recursive = true; - return GetResult(collections, parent, query); + return _libraryManager.GetItemsResult(query); } private async Task> GetTvView(Folder parent, User user, InternalItemsQuery query) @@ -1735,7 +1740,7 @@ namespace MediaBrowser.Controller.Entities if (query.SeriesStatuses.Length > 0) { - var ok = new[] { item }.OfType().Any(p => p.Status.HasValue && query.SeriesStatuses.Contains(p.Status.Value)); + var ok = new[] { item }.OfType().Any(p => p.Status.HasValue && query.SeriesStatuses.Contains(p.Status.Value)); if (!ok) { return false; From bb5a17780c3e08b43500c8caf47df914ebb3cdba Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 15 May 2016 15:49:50 -0400 Subject: [PATCH 4/9] optimize dlna queries --- .../Entities/UserViewBuilder.cs | 160 +++++++++++------- 1 file changed, 99 insertions(+), 61 deletions(-) diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index caf160f02..f58debf93 100644 --- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs +++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs @@ -310,14 +310,14 @@ namespace MediaBrowser.Controller.Entities private async Task> GetMusicGenreItems(Folder queryParent, Folder displayParent, User user, InternalItemsQuery query) { - var items = GetRecursiveChildren(queryParent, user, new[] { CollectionType.Music, CollectionType.MusicVideos }) - .Where(i => !i.IsFolder) - .Where(i => i.Genres.Contains(displayParent.Name, StringComparer.OrdinalIgnoreCase)) - .OfType(); + query.Recursive = true; + query.ParentId = queryParent.Id; + query.Genres = new[] { displayParent.Name }; + query.SetUser(user); - var artists = _libraryManager.GetAlbumArtists(items); + query.IncludeItemTypes = new[] { typeof(MusicAlbum).Name }; - return GetResult(artists, queryParent, query); + return _libraryManager.GetItemsResult(query); } private QueryResult GetMusicAlbumArtists(Folder parent, User user, InternalItemsQuery query) @@ -365,16 +365,24 @@ namespace MediaBrowser.Controller.Entities private QueryResult GetMusicAlbums(Folder parent, User user, InternalItemsQuery query) { - var items = GetRecursiveChildren(parent, user, new[] { CollectionType.Music, CollectionType.MusicVideos }, i => i is MusicAlbum && FilterItem(i, query)); + query.Recursive = true; + query.ParentId = parent.Id; + query.SetUser(user); - return PostFilterAndSort(items, parent, null, query); + query.IncludeItemTypes = new[] { typeof(MusicAlbum).Name }; + + return _libraryManager.GetItemsResult(query); } private QueryResult GetMusicSongs(Folder parent, User user, InternalItemsQuery query) { - var items = GetRecursiveChildren(parent, user, new[] { CollectionType.Music, CollectionType.MusicVideos }, i => i is Audio.Audio && FilterItem(i, query)); + query.Recursive = true; + query.ParentId = parent.Id; + query.SetUser(user); - return PostFilterAndSort(items, parent, null, query); + query.IncludeItemTypes = new[] { typeof(Audio.Audio).Name }; + + return _libraryManager.GetItemsResult(query); } private QueryResult GetMusicLatest(Folder parent, User user, InternalItemsQuery query) @@ -398,20 +406,24 @@ namespace MediaBrowser.Controller.Entities private QueryResult GetFavoriteSongs(Folder parent, User user, InternalItemsQuery query) { + query.Recursive = true; + query.ParentId = parent.Id; + query.SetUser(user); query.IsFavorite = true; + query.IncludeItemTypes = new[] { typeof(Audio.Audio).Name }; - var items = GetRecursiveChildren(parent, user, new[] { CollectionType.Music }, i => i is Audio.Audio && FilterItem(i, query)); - - return PostFilterAndSort(items, parent, null, query); + return _libraryManager.GetItemsResult(query); } private QueryResult GetFavoriteAlbums(Folder parent, User user, InternalItemsQuery query) { + query.Recursive = true; + query.ParentId = parent.Id; + query.SetUser(user); query.IsFavorite = true; + query.IncludeItemTypes = new[] { typeof(MusicAlbum).Name }; - var items = GetRecursiveChildren(parent, user, new[] { CollectionType.Music }, i => i is MusicAlbum && FilterItem(i, query)); - - return PostFilterAndSort(items, parent, null, query); + return _libraryManager.GetItemsResult(query); } private async Task> FindPlaylists(Folder parent, User user, InternalItemsQuery query) @@ -430,19 +442,13 @@ namespace MediaBrowser.Controller.Entities { if (query.Recursive) { - var recursiveItems = GetRecursiveChildren(parent, user, - new[] { CollectionType.Movies, CollectionType.BoxSets, string.Empty }) - .Where(i => i is Movie || i is BoxSet); + query.Recursive = true; + query.ParentId = parent.Id; + query.SetUser(user); - //var collections = _collectionManager.CollapseItemsWithinBoxSets(recursiveItems, user).ToList(); + query.IncludeItemTypes = new[] { typeof(Movie).Name, typeof(BoxSet).Name }; - //if (collections.Count > 0) - //{ - // recursiveItems.AddRange(_collectionManager.CollapseItemsWithinBoxSets(recursiveItems, user)); - // recursiveItems = recursiveItems.DistinctBy(i => i.Id).ToList(); - //} - - return GetResult(recursiveItems, parent, query); + return _libraryManager.GetItemsResult(query); } var list = new List(); @@ -459,43 +465,51 @@ namespace MediaBrowser.Controller.Entities private QueryResult GetFavoriteMovies(Folder parent, User user, InternalItemsQuery query) { + query.Recursive = true; + query.ParentId = parent.Id; + query.SetUser(user); query.IsFavorite = true; + query.IncludeItemTypes = new[] { typeof(Movie).Name }; - var items = GetRecursiveChildren(parent, user, new[] { CollectionType.Movies, CollectionType.BoxSets, string.Empty }, i => i is Movie && FilterItem(i, query)); - - return PostFilterAndSort(items, parent, null, query); + return _libraryManager.GetItemsResult(query); } private QueryResult GetFavoriteSeries(Folder parent, User user, InternalItemsQuery query) { + query.Recursive = true; + query.ParentId = parent.Id; + query.SetUser(user); query.IsFavorite = true; + query.IncludeItemTypes = new[] { typeof(Series).Name }; - var items = GetRecursiveChildren(parent, user, new[] { CollectionType.TvShows, string.Empty }, i => i is Series && FilterItem(i, query)); - - return PostFilterAndSort(items, parent, null, query); + return _libraryManager.GetItemsResult(query); } private QueryResult GetFavoriteEpisodes(Folder parent, User user, InternalItemsQuery query) { + query.Recursive = true; + query.ParentId = parent.Id; + query.SetUser(user); query.IsFavorite = true; + query.IncludeItemTypes = new[] { typeof(Episode).Name }; - var items = GetRecursiveChildren(parent, user, new[] { CollectionType.TvShows, string.Empty }, i => i is Episode && FilterItem(i, query)); - - return PostFilterAndSort(items, parent, null, query); + return _libraryManager.GetItemsResult(query); } private QueryResult GetMovieMovies(Folder parent, User user, InternalItemsQuery query) { - var items = GetRecursiveChildren(parent, user, new[] { CollectionType.Movies, CollectionType.BoxSets, string.Empty }, i => i is Movie && FilterItem(i, query)); + query.Recursive = true; + query.ParentId = parent.Id; + query.SetUser(user); - return PostFilterAndSort(items, parent, null, query); + query.IncludeItemTypes = new[] { typeof(Movie).Name }; + + return _libraryManager.GetItemsResult(query); } private QueryResult GetMovieCollections(Folder parent, User user, InternalItemsQuery query) { - var items = GetRecursiveChildren(parent, user, new[] { CollectionType.Movies, CollectionType.BoxSets, string.Empty }, i => i is BoxSet && FilterItem(i, query)); - - return PostFilterAndSort(items, parent, null, query); + return GetBoxsetView(parent, user, query); } private QueryResult GetMovieLatest(Folder parent, User user, InternalItemsQuery query) @@ -503,9 +517,13 @@ namespace MediaBrowser.Controller.Entities query.SortBy = new[] { ItemSortBy.DateCreated, ItemSortBy.SortName }; query.SortOrder = SortOrder.Descending; - var items = GetRecursiveChildren(parent, user, new[] { CollectionType.Movies, CollectionType.BoxSets, string.Empty }, i => i is Movie && FilterItem(i, query)); + query.Recursive = true; + query.ParentId = parent.Id; + query.SetUser(user); + query.Limit = GetSpecialItemsLimit(); + query.IncludeItemTypes = new[] { typeof(Movie).Name }; - return PostFilterAndSort(items, parent, GetSpecialItemsLimit(), query); + return _libraryManager.GetItemsResult(query); } private QueryResult GetMovieResume(Folder parent, User user, InternalItemsQuery query) @@ -513,10 +531,13 @@ namespace MediaBrowser.Controller.Entities query.SortBy = new[] { ItemSortBy.DatePlayed, ItemSortBy.SortName }; query.SortOrder = SortOrder.Descending; query.IsResumable = true; + query.Recursive = true; + query.ParentId = parent.Id; + query.SetUser(user); + query.Limit = GetSpecialItemsLimit(); + query.IncludeItemTypes = new[] { typeof(Movie).Name }; - var items = GetRecursiveChildren(parent, user, new[] { CollectionType.Movies, CollectionType.BoxSets, string.Empty }, i => i is Movie && FilterItem(i, query)); - - return PostFilterAndSort(items, parent, GetSpecialItemsLimit(), query); + return _libraryManager.GetItemsResult(query); } private async Task> GetMovieGenres(Folder parent, User user, InternalItemsQuery query) @@ -549,11 +570,14 @@ namespace MediaBrowser.Controller.Entities private async Task> GetMovieGenreItems(Folder queryParent, Folder displayParent, User user, InternalItemsQuery query) { - var items = GetRecursiveChildren(queryParent, user, new[] { CollectionType.Movies, CollectionType.BoxSets, string.Empty }) - .Where(i => i is Movie) - .Where(i => i.Genres.Contains(displayParent.Name, StringComparer.OrdinalIgnoreCase)); + query.Recursive = true; + query.ParentId = queryParent.Id; + query.Genres = new[] { displayParent.Name }; + query.SetUser(user); - return GetResult(items, queryParent, query); + query.IncludeItemTypes = new[] { typeof(Movie).Name }; + + return _libraryManager.GetItemsResult(query); } private async Task> GetPlaylistsView(Folder parent, User user, InternalItemsQuery query) @@ -598,9 +622,13 @@ namespace MediaBrowser.Controller.Entities query.SortBy = new[] { ItemSortBy.DateCreated, ItemSortBy.SortName }; query.SortOrder = SortOrder.Descending; - var items = GetRecursiveChildren(parent, user, new[] { CollectionType.TvShows, string.Empty }, i => i is Episode && FilterItem(i, query)); + query.Recursive = true; + query.ParentId = parent.Id; + query.SetUser(user); + query.Limit = GetSpecialItemsLimit(); + query.IncludeItemTypes = new[] { typeof(Episode).Name }; - return PostFilterAndSort(items, parent, GetSpecialItemsLimit(), query); + return _libraryManager.GetItemsResult(query); } private QueryResult GetTvNextUp(Folder parent, InternalItemsQuery query) @@ -623,17 +651,24 @@ namespace MediaBrowser.Controller.Entities query.SortBy = new[] { ItemSortBy.DatePlayed, ItemSortBy.SortName }; query.SortOrder = SortOrder.Descending; query.IsResumable = true; + query.Recursive = true; + query.ParentId = parent.Id; + query.SetUser(user); + query.Limit = GetSpecialItemsLimit(); + query.IncludeItemTypes = new[] { typeof(Episode).Name }; - var items = GetRecursiveChildren(parent, user, new[] { CollectionType.TvShows, string.Empty }, i => i is Episode && FilterItem(i, query)); - - return PostFilterAndSort(items, parent, GetSpecialItemsLimit(), query); + return _libraryManager.GetItemsResult(query); } private QueryResult GetTvSeries(Folder parent, User user, InternalItemsQuery query) { - var items = GetRecursiveChildren(parent, user, new[] { CollectionType.TvShows, string.Empty }, i => i is Series && FilterItem(i, query)); + query.Recursive = true; + query.ParentId = parent.Id; + query.SetUser(user); - return PostFilterAndSort(items, parent, null, query); + query.IncludeItemTypes = new[] { typeof(Series).Name }; + + return _libraryManager.GetItemsResult(query); } private async Task> GetTvGenres(Folder parent, User user, InternalItemsQuery query) @@ -666,11 +701,14 @@ namespace MediaBrowser.Controller.Entities private async Task> GetTvGenreItems(Folder queryParent, Folder displayParent, User user, InternalItemsQuery query) { - var items = GetRecursiveChildren(queryParent, user, new[] { CollectionType.TvShows, string.Empty }) - .Where(i => i is Series) - .Where(i => i.Genres.Contains(displayParent.Name, StringComparer.OrdinalIgnoreCase)); + query.Recursive = true; + query.ParentId = queryParent.Id; + query.Genres = new[] { displayParent.Name }; + query.SetUser(user); - return GetResult(items, queryParent, query); + query.IncludeItemTypes = new[] { typeof(Series).Name }; + + return _libraryManager.GetItemsResult(query); } private QueryResult GetResult(QueryResult result) From 5f1e0cf2d344d6fdbc18b09d6ab3552e208434c1 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 15 May 2016 15:55:17 -0400 Subject: [PATCH 5/9] optimize dlna queries --- MediaBrowser.Controller/Entities/UserViewBuilder.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index f58debf93..a4fe2e178 100644 --- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs +++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs @@ -399,8 +399,6 @@ namespace MediaBrowser.Controller.Entities query.SortBy = new string[] { }; - //var items = GetRecursiveChildren(parent, user, new[] { CollectionType.Music, CollectionType.MusicVideos }, i => i is MusicVideo || i is Audio.Audio && FilterItem(i, query)); - return PostFilterAndSort(items, parent, null, query); } @@ -599,9 +597,13 @@ namespace MediaBrowser.Controller.Entities { if (query.Recursive) { - var items = GetRecursiveChildren(parent, user, new[] { CollectionType.TvShows, string.Empty }, i => (i is Series || i is Season || i is Episode) && FilterItem(i, query)); + query.Recursive = true; + query.ParentId = parent.Id; + query.SetUser(user); - return PostFilterAndSort(items, parent, null, query); + query.IncludeItemTypes = new[] { typeof(Series).Name, typeof(Season).Name, typeof(Episode).Name }; + + return _libraryManager.GetItemsResult(query); } var list = new List(); From 862f681f7aa94b386bb36caa8ba037f900e6889f Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 15 May 2016 15:55:58 -0400 Subject: [PATCH 6/9] 3.0.5972 --- SharedVersion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SharedVersion.cs b/SharedVersion.cs index be2afd1c1..5519f0dfd 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,4 +1,4 @@ using System.Reflection; //[assembly: AssemblyVersion("3.0.*")] -[assembly: AssemblyVersion("3.0.5971")] +[assembly: AssemblyVersion("3.0.5972")] From 233f9cb238201c7dfdb060b718ff635947161f30 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 15 May 2016 21:22:22 -0400 Subject: [PATCH 7/9] update shared components --- .../LiveTv/LiveTvManager.cs | 13 +++++++------ .../Notifications/SqliteNotificationsRepository.cs | 3 ++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index 99ab07648..9251ccb9e 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -1385,6 +1385,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv private QueryResult GetEmbyRecordings(RecordingQuery query, User user) { + if (user == null || (query.IsInProgress ?? false)) + { + return new QueryResult(); + } + var folders = EmbyTV.EmbyTV.Current.GetRecordingFolders() .SelectMany(i => i.Locations) .Distinct(StringComparer.OrdinalIgnoreCase) @@ -1413,13 +1418,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv return new QueryResult(); } - if (user != null && !(query.IsInProgress ?? false)) + if (_services.Count == 1) { - var initialResult = GetEmbyRecordings(query, user); - if (initialResult.TotalRecordCount > 0) - { - return initialResult; - } + return GetEmbyRecordings(query, user); } await RefreshRecordings(cancellationToken).ConfigureAwait(false); diff --git a/MediaBrowser.Server.Implementations/Notifications/SqliteNotificationsRepository.cs b/MediaBrowser.Server.Implementations/Notifications/SqliteNotificationsRepository.cs index cecf03ddf..10e8c5699 100644 --- a/MediaBrowser.Server.Implementations/Notifications/SqliteNotificationsRepository.cs +++ b/MediaBrowser.Server.Implementations/Notifications/SqliteNotificationsRepository.cs @@ -41,7 +41,8 @@ namespace MediaBrowser.Server.Implementations.Notifications string[] queries = { "create table if not exists Notifications (Id GUID NOT NULL, UserId GUID NOT NULL, Date DATETIME NOT NULL, Name TEXT NOT NULL, Description TEXT, Url TEXT, Level TEXT NOT NULL, IsRead BOOLEAN NOT NULL, Category TEXT NOT NULL, RelatedId TEXT, PRIMARY KEY (Id, UserId))", - "create index if not exists idx_Notifications on Notifications(Id, UserId)", + "create index if not exists idx_Notifications1 on Notifications(Id)", + "create index if not exists idx_Notifications2 on Notifications(UserId)", //pragmas "pragma temp_store = memory", From 82ad4941894b3535e773c11cbef08986c4274a02 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 16 May 2016 01:47:40 -0400 Subject: [PATCH 8/9] fix project --- MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj | 6 ------ 1 file changed, 6 deletions(-) diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index e6d690f27..0061ec5de 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -140,12 +140,6 @@ PreserveNewest - - PreserveNewest - - - PreserveNewest - PreserveNewest From bf89f347e84e7d2120319c7c59510e8bce151b80 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 16 May 2016 01:48:30 -0400 Subject: [PATCH 9/9] 3.0.5973 --- SharedVersion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SharedVersion.cs b/SharedVersion.cs index 5519f0dfd..ada1802b9 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,4 +1,4 @@ using System.Reflection; //[assembly: AssemblyVersion("3.0.*")] -[assembly: AssemblyVersion("3.0.5972")] +[assembly: AssemblyVersion("3.0.5973")]