From 4b7093e923b457f34f717f286ebb08514cfb9067 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 20 Mar 2016 02:46:51 -0400 Subject: get recursive items from db --- .../Entities/UserViewBuilder.cs | 40 ++++++++++++++++------ 1 file changed, 30 insertions(+), 10 deletions(-) (limited to 'MediaBrowser.Controller/Entities/UserViewBuilder.cs') diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index 721ec3f1b..4439b9c6d 100644 --- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs +++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs @@ -50,15 +50,15 @@ namespace MediaBrowser.Controller.Entities { var user = query.User; - if (query.IncludeItemTypes != null && - query.IncludeItemTypes.Length == 1 && - string.Equals(query.IncludeItemTypes[0], "Playlist", StringComparison.OrdinalIgnoreCase)) - { - if (!string.Equals(viewType, CollectionType.Playlists, StringComparison.OrdinalIgnoreCase)) - { - return await FindPlaylists(queryParent, user, query).ConfigureAwait(false); - } - } + //if (query.IncludeItemTypes != null && + // query.IncludeItemTypes.Length == 1 && + // string.Equals(query.IncludeItemTypes[0], "Playlist", StringComparison.OrdinalIgnoreCase)) + //{ + // if (!string.Equals(viewType, CollectionType.Playlists, StringComparison.OrdinalIgnoreCase)) + // { + // return await FindPlaylists(queryParent, user, query).ConfigureAwait(false); + // } + //} switch (viewType) { @@ -766,7 +766,7 @@ namespace MediaBrowser.Controller.Entities return items; } - private static bool CollapseBoxSetItems(InternalItemsQuery query, + public static bool CollapseBoxSetItems(InternalItemsQuery query, BaseItem queryParent, User user) { @@ -1689,6 +1689,26 @@ namespace MediaBrowser.Controller.Entities } } + if (query.MinPremiereDate.HasValue) + { + var val = query.MinPremiereDate.Value; + + if (!(item.PremiereDate.HasValue && item.PremiereDate.Value >= val)) + { + return false; + } + } + + if (query.MaxPremiereDate.HasValue) + { + var val = query.MaxPremiereDate.Value; + + if (!(item.PremiereDate.HasValue && item.PremiereDate.Value <= val)) + { + return false; + } + } + return true; } -- cgit v1.2.3 From b4ea519395031f87a4c5154c34bccc621fc2dd95 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 20 Mar 2016 15:53:22 -0400 Subject: update db querying --- MediaBrowser.Api/Reports/ReportsService.cs | 97 ++++++---------------- MediaBrowser.Api/UserLibrary/ItemsService.cs | 97 ++++++---------------- MediaBrowser.Controller/Entities/Folder.cs | 25 +++--- .../Entities/InternalItemsQuery.cs | 9 +- .../Entities/UserViewBuilder.cs | 28 +++++++ .../Persistence/CleanDatabaseScheduledTask.cs | 4 +- .../Persistence/SqliteItemRepository.cs | 52 ++++++++---- Nuget/MediaBrowser.Common.Internal.nuspec | 4 +- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Model.Signed.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +- 11 files changed, 144 insertions(+), 180 deletions(-) (limited to 'MediaBrowser.Controller/Entities/UserViewBuilder.cs') diff --git a/MediaBrowser.Api/Reports/ReportsService.cs b/MediaBrowser.Api/Reports/ReportsService.cs index d3e9abe69..59e969235 100644 --- a/MediaBrowser.Api/Reports/ReportsService.cs +++ b/MediaBrowser.Api/Reports/ReportsService.cs @@ -258,7 +258,8 @@ namespace MediaBrowser.Api.Reports MinPlayers = request.MinPlayers, MaxPlayers = request.MaxPlayers, MinCommunityRating = request.MinCommunityRating, - MinCriticRating = request.MinCriticRating + MinCriticRating = request.MinCriticRating, + ParentIndexNumber = request.ParentIndexNumber }; if (!string.IsNullOrWhiteSpace(request.Ids)) @@ -312,6 +313,29 @@ namespace MediaBrowser.Api.Reports query.MaxPremiereDate = DateTime.Parse(request.MaxPremiereDate, null, DateTimeStyles.RoundtripKind).ToUniversalTime(); } + // Filter by Series Status + if (!string.IsNullOrEmpty(request.SeriesStatus)) + { + query.SeriesStatuses = request.SeriesStatus.Split(',').Select(d => (SeriesStatus)Enum.Parse(typeof(SeriesStatus), d, true)).ToArray(); + } + + // Filter by Series AirDays + if (!string.IsNullOrEmpty(request.AirDays)) + { + query.AirDays = request.AirDays.Split(',').Select(d => (DayOfWeek)Enum.Parse(typeof(DayOfWeek), d, true)).ToArray(); + } + + // ExcludeLocationTypes + if (!string.IsNullOrEmpty(request.ExcludeLocationTypes)) + { + query.ExcludeLocationTypes = request.ExcludeLocationTypes.Split(',').Select(d => (LocationType)Enum.Parse(typeof(LocationType), d, true)).ToArray(); + } + + if (!string.IsNullOrEmpty(request.LocationTypes)) + { + query.LocationTypes = request.LocationTypes.Split(',').Select(d => (LocationType)Enum.Parse(typeof(LocationType), d, true)).ToArray(); + } + if (request.HasQueryLimit == false) { query.StartIndex = null; @@ -452,26 +476,6 @@ namespace MediaBrowser.Api.Reports } } - // LocationTypes - if (!string.IsNullOrEmpty(request.LocationTypes)) - { - var vals = request.LocationTypes.Split(','); - if (!vals.Contains(i.LocationType.ToString(), StringComparer.OrdinalIgnoreCase)) - { - return false; - } - } - - // ExcludeLocationTypes - if (!string.IsNullOrEmpty(request.ExcludeLocationTypes)) - { - var vals = request.ExcludeLocationTypes.Split(','); - if (vals.Contains(i.LocationType.ToString(), StringComparer.OrdinalIgnoreCase)) - { - return false; - } - } - if (!string.IsNullOrEmpty(request.AlbumArtistStartsWithOrGreater)) { var ok = new[] { i }.OfType() @@ -483,57 +487,6 @@ namespace MediaBrowser.Api.Reports } } - // Filter by Series Status - if (!string.IsNullOrEmpty(request.SeriesStatus)) - { - var vals = request.SeriesStatus.Split(','); - - var ok = new[] { i }.OfType().Any(p => p.Status.HasValue && vals.Contains(p.Status.Value.ToString(), StringComparer.OrdinalIgnoreCase)); - - if (!ok) - { - return false; - } - } - - // Filter by Series AirDays - if (!string.IsNullOrEmpty(request.AirDays)) - { - var days = request.AirDays.Split(',').Select(d => (DayOfWeek)Enum.Parse(typeof(DayOfWeek), d, true)); - - var ok = new[] { i }.OfType().Any(p => p.AirDays != null && days.Any(d => p.AirDays.Contains(d))); - - if (!ok) - { - return false; - } - } - - if (request.ParentIndexNumber.HasValue) - { - var filterValue = request.ParentIndexNumber.Value; - - var episode = i as Episode; - - if (episode != null) - { - if (episode.ParentIndexNumber.HasValue && episode.ParentIndexNumber.Value != filterValue) - { - return false; - } - } - - var song = i as Audio; - - if (song != null) - { - if (song.ParentIndexNumber.HasValue && song.ParentIndexNumber.Value != filterValue) - { - return false; - } - } - } - if (request.AiredDuringSeason.HasValue) { var episode = i as Episode; diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index e739ac7c2..a48fcbc93 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -231,7 +231,8 @@ namespace MediaBrowser.Api.UserLibrary MaxPlayers = request.MaxPlayers, MinCommunityRating = request.MinCommunityRating, MinCriticRating = request.MinCriticRating, - ParentId = string.IsNullOrWhiteSpace(request.ParentId) ? (Guid?)null : new Guid(request.ParentId) + ParentId = string.IsNullOrWhiteSpace(request.ParentId) ? (Guid?)null : new Guid(request.ParentId), + ParentIndexNumber = request.ParentIndexNumber }; if (!string.IsNullOrWhiteSpace(request.Ids)) @@ -285,6 +286,29 @@ namespace MediaBrowser.Api.UserLibrary query.MaxPremiereDate = DateTime.Parse(request.MaxPremiereDate, null, DateTimeStyles.RoundtripKind).ToUniversalTime(); } + // Filter by Series Status + if (!string.IsNullOrEmpty(request.SeriesStatus)) + { + query.SeriesStatuses = request.SeriesStatus.Split(',').Select(d => (SeriesStatus)Enum.Parse(typeof(SeriesStatus), d, true)).ToArray(); + } + + // Filter by Series AirDays + if (!string.IsNullOrEmpty(request.AirDays)) + { + query.AirDays = request.AirDays.Split(',').Select(d => (DayOfWeek)Enum.Parse(typeof(DayOfWeek), d, true)).ToArray(); + } + + // ExcludeLocationTypes + if (!string.IsNullOrEmpty(request.ExcludeLocationTypes)) + { + query.ExcludeLocationTypes = request.ExcludeLocationTypes.Split(',').Select(d => (LocationType)Enum.Parse(typeof(LocationType), d, true)).ToArray(); + } + + if (!string.IsNullOrEmpty(request.LocationTypes)) + { + query.LocationTypes = request.LocationTypes.Split(',').Select(d => (LocationType)Enum.Parse(typeof(LocationType), d, true)).ToArray(); + } + return query; } @@ -410,26 +434,6 @@ namespace MediaBrowser.Api.UserLibrary } } - // LocationTypes - if (!string.IsNullOrEmpty(request.LocationTypes)) - { - var vals = request.LocationTypes.Split(','); - if (!vals.Contains(i.LocationType.ToString(), StringComparer.OrdinalIgnoreCase)) - { - return false; - } - } - - // ExcludeLocationTypes - if (!string.IsNullOrEmpty(request.ExcludeLocationTypes)) - { - var vals = request.ExcludeLocationTypes.Split(','); - if (vals.Contains(i.LocationType.ToString(), StringComparer.OrdinalIgnoreCase)) - { - return false; - } - } - if (!string.IsNullOrEmpty(request.AlbumArtistStartsWithOrGreater)) { var ok = new[] { i }.OfType() @@ -441,57 +445,6 @@ namespace MediaBrowser.Api.UserLibrary } } - // Filter by Series Status - if (!string.IsNullOrEmpty(request.SeriesStatus)) - { - var vals = request.SeriesStatus.Split(','); - - var ok = new[] { i }.OfType().Any(p => p.Status.HasValue && vals.Contains(p.Status.Value.ToString(), StringComparer.OrdinalIgnoreCase)); - - if (!ok) - { - return false; - } - } - - // Filter by Series AirDays - if (!string.IsNullOrEmpty(request.AirDays)) - { - var days = request.AirDays.Split(',').Select(d => (DayOfWeek)Enum.Parse(typeof(DayOfWeek), d, true)); - - var ok = new[] { i }.OfType().Any(p => p.AirDays != null && days.Any(d => p.AirDays.Contains(d))); - - if (!ok) - { - return false; - } - } - - if (request.ParentIndexNumber.HasValue) - { - var filterValue = request.ParentIndexNumber.Value; - - var episode = i as Episode; - - if (episode != null) - { - if (episode.ParentIndexNumber.HasValue && episode.ParentIndexNumber.Value != filterValue) - { - return false; - } - } - - var song = i as Audio; - - if (song != null) - { - if (song.ParentIndexNumber.HasValue && song.ParentIndexNumber.Value != filterValue) - { - return false; - } - } - } - if (request.AiredDuringSeason.HasValue) { var episode = i as Episode; diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index efb784153..5a5fe2a9f 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -1094,13 +1094,6 @@ namespace MediaBrowser.Controller.Entities return true; } - // Apply year filter - if (query.Years.Length > 0) - { - Logger.Debug("Query requires post-filtering due to Years"); - return true; - } - // Apply official rating filter if (query.OfficialRatings.Length > 0) { @@ -1139,12 +1132,6 @@ namespace MediaBrowser.Controller.Entities return true; } - if (query.Years.Length > 0) - { - Logger.Debug("Query requires post-filtering due to Years"); - return true; - } - if (query.OfficialRatings.Length > 0) { Logger.Debug("Query requires post-filtering due to OfficialRatings"); @@ -1205,6 +1192,18 @@ namespace MediaBrowser.Controller.Entities return true; } + if (query.AirDays.Length > 0) + { + Logger.Debug("Query requires post-filtering due to AirDays"); + return true; + } + + if (query.SeriesStatuses.Length > 0) + { + Logger.Debug("Query requires post-filtering due to SeriesStatuses"); + return true; + } + return false; } diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs index 05031691c..e2b393d4d 100644 --- a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs +++ b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs @@ -103,17 +103,18 @@ namespace MediaBrowser.Controller.Entities public string[] ChannelIds { get; set; } internal List ItemIdsFromPersonFilters { get; set; } + public int? ParentIndexNumber { get; set; } public int? MaxParentalRating { get; set; } public bool? IsCurrentSchema { get; set; } public bool? HasDeadParentId { get; set; } public bool? IsOffline { get; set; } - public LocationType? LocationType { get; set; } public Guid? ParentId { get; set; } public string[] AncestorIds { get; set; } public string[] TopParentIds { get; set; } + public LocationType[] LocationTypes { get; set; } public LocationType[] ExcludeLocationTypes { get; set; } public string[] PresetViews { get; set; } public SourceType[] SourceTypes { get; set; } @@ -121,6 +122,9 @@ namespace MediaBrowser.Controller.Entities public TrailerType[] TrailerTypes { get; set; } public TrailerType[] ExcludeTrailerTypes { get; set; } + public DayOfWeek[] AirDays { get; set; } + public SeriesStatus[] SeriesStatuses { get; set; } + public InternalItemsQuery() { BlockUnratedItems = new UnratedItem[] { }; @@ -144,12 +148,15 @@ namespace MediaBrowser.Controller.Entities AncestorIds = new string[] { }; TopParentIds = new string[] { }; ExcludeTags = new string[] { }; + LocationTypes = new LocationType[] { }; ExcludeLocationTypes = new LocationType[] { }; PresetViews = new string[] { }; SourceTypes = new SourceType[] { }; ExcludeSourceTypes = new SourceType[] { }; TrailerTypes = new TrailerType[] { }; ExcludeTrailerTypes = new TrailerType[] { }; + AirDays = new DayOfWeek[] { }; + SeriesStatuses = new SeriesStatus[] { }; } public InternalItemsQuery(User user) diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index 4439b9c6d..c33212619 100644 --- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs +++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs @@ -1709,6 +1709,34 @@ namespace MediaBrowser.Controller.Entities } } + if (query.ParentIndexNumber.HasValue) + { + var filterValue = query.ParentIndexNumber.Value; + + if (item.ParentIndexNumber.HasValue && item.ParentIndexNumber.Value != filterValue) + { + return false; + } + } + + if (query.AirDays.Length > 0) + { + var ok = new[] { item }.OfType().Any(p => p.AirDays != null && query.AirDays.Any(d => p.AirDays.Contains(d))); + if (!ok) + { + return false; + } + } + + if (query.SeriesStatuses.Length > 0) + { + var ok = new[] { item }.OfType().Any(p => p.Status.HasValue && query.SeriesStatuses.Contains(p.Status.Value)); + if (!ok) + { + return false; + } + } + return true; } diff --git a/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs b/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs index 028d9eb1f..bec105b0a 100644 --- a/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs +++ b/MediaBrowser.Server.Implementations/Persistence/CleanDatabaseScheduledTask.cs @@ -208,7 +208,7 @@ namespace MediaBrowser.Server.Implementations.Persistence await item.Delete(new DeleteOptions { DeleteFileLocation = false - + }).ConfigureAwait(false); } @@ -225,7 +225,7 @@ namespace MediaBrowser.Server.Implementations.Persistence { var result = _itemRepo.GetItemIdsWithPath(new InternalItemsQuery { - LocationType = LocationType.FileSystem, + LocationTypes = new[] { LocationType.FileSystem }, //Limit = limit, // These have their own cleanup routines diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs index 491f2c116..e17b7d953 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs @@ -80,7 +80,7 @@ namespace MediaBrowser.Server.Implementations.Persistence private IDbCommand _saveAncestorCommand; private IDbCommand _updateInheritedRatingCommand; - + private const int LatestSchemaVersion = 48; /// @@ -160,7 +160,7 @@ namespace MediaBrowser.Server.Implementations.Persistence _connection.RunQueries(queries, Logger); _connection.AddColumn(Logger, "AncestorIds", "AncestorIdText", "Text"); - + _connection.AddColumn(Logger, "TypedBaseItems", "Path", "Text"); _connection.AddColumn(Logger, "TypedBaseItems", "StartDate", "DATETIME"); _connection.AddColumn(Logger, "TypedBaseItems", "EndDate", "DATETIME"); @@ -1809,11 +1809,6 @@ namespace MediaBrowser.Server.Implementations.Persistence whereClauses.Add("IsOffline=@IsOffline"); cmd.Parameters.Add(cmd, "@IsOffline", DbType.Boolean).Value = query.IsOffline; } - if (query.LocationType.HasValue) - { - whereClauses.Add("LocationType=@LocationType"); - cmd.Parameters.Add(cmd, "@LocationType", DbType.String).Value = query.LocationType.Value; - } if (query.IsMovie.HasValue) { whereClauses.Add("IsMovie=@IsMovie"); @@ -1906,6 +1901,11 @@ namespace MediaBrowser.Server.Implementations.Persistence // cmd.Parameters.Add(cmd, "@MaxPlayers", DbType.Int32).Value = query.MaxPlayers.Value; //} + if (query.ParentIndexNumber.HasValue) + { + whereClauses.Add("ParentIndexNumber=@MinEndDate"); + cmd.Parameters.Add(cmd, "@ParentIndexNumber", DbType.Int32).Value = query.ParentIndexNumber.Value; + } if (query.MinEndDate.HasValue) { whereClauses.Add("EndDate>=@MinEndDate"); @@ -1990,7 +1990,7 @@ namespace MediaBrowser.Server.Implementations.Persistence var clause = "(" + string.Join(" AND ", clauses.ToArray()) + ")"; whereClauses.Add(clause); } - + if (query.IsAiring.HasValue) { if (query.IsAiring.Value) @@ -2087,12 +2087,36 @@ namespace MediaBrowser.Server.Implementations.Persistence whereClauses.Add("ParentId NOT NULL AND ParentId NOT IN (select guid from TypedBaseItems)"); } } + + if (query.Years.Length == 1) + { + whereClauses.Add("ProductionYear=@Years"); + cmd.Parameters.Add(cmd, "@Years", DbType.Int32).Value = query.Years[0].ToString(); + } + else if (query.Years.Length > 1) + { + var val = string.Join(",", query.Years.ToArray()); + + whereClauses.Add("ProductionYear in (" + val + ")"); + } + + if (query.LocationTypes.Length == 1) + { + whereClauses.Add("LocationType=@LocationType"); + cmd.Parameters.Add(cmd, "@LocationType", DbType.String).Value = query.LocationTypes[0].ToString(); + } + else if (query.LocationTypes.Length > 1) + { + var val = string.Join(",", query.LocationTypes.Select(i => "'" + i + "'").ToArray()); + + whereClauses.Add("LocationType in (" + val + ")"); + } if (query.ExcludeLocationTypes.Length == 1) { - whereClauses.Add("LocationType<>@LocationType"); - cmd.Parameters.Add(cmd, "@LocationType", DbType.String).Value = query.ExcludeLocationTypes[0].ToString(); + whereClauses.Add("LocationType<>@ExcludeLocationTypes"); + cmd.Parameters.Add(cmd, "@ExcludeLocationTypes", DbType.String).Value = query.ExcludeLocationTypes[0].ToString(); } - if (query.ExcludeLocationTypes.Length > 1) + else if (query.ExcludeLocationTypes.Length > 1) { var val = string.Join(",", query.ExcludeLocationTypes.Select(i => "'" + i + "'").ToArray()); @@ -2128,7 +2152,7 @@ namespace MediaBrowser.Server.Implementations.Persistence if (query.TopParentIds.Length > 1) { var val = string.Join(",", query.TopParentIds.Select(i => "'" + i + "'").ToArray()); - + if (enableItemsByName) { whereClauses.Add("(IsItemByName=@IsItemByName or TopParentId in (" + val + "))"); @@ -2169,7 +2193,7 @@ namespace MediaBrowser.Server.Implementations.Persistence cmd.Parameters.Add(cmd, "@excludeTag" + excludeTagIndex, DbType.String).Value = "%" + excludeTag + "%"; excludeTagIndex++; } - + if (addPaging) { if (query.StartIndex.HasValue && query.StartIndex.Value > 0) @@ -2252,7 +2276,7 @@ namespace MediaBrowser.Server.Implementations.Persistence { return; } - + await WriteLock.WaitAsync(cancellationToken).ConfigureAwait(false); IDbTransaction transaction = null; diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index 259eb6f89..10a898785 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.643 + 3.0.644 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Emby Theater and Emby Server. Not intended for plugin developer consumption. Copyright © Emby 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index d1cb66cbb..616f0ca2a 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.643 + 3.0.644 MediaBrowser.Common Emby Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Model.Signed.nuspec b/Nuget/MediaBrowser.Model.Signed.nuspec index 056359ae4..d17ff16b6 100644 --- a/Nuget/MediaBrowser.Model.Signed.nuspec +++ b/Nuget/MediaBrowser.Model.Signed.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Model.Signed - 3.0.643 + 3.0.644 MediaBrowser.Model - Signed Edition Emby Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index 6737a432f..2098bbcfe 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.643 + 3.0.644 Media Browser.Server.Core Emby Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Emby Server. Copyright © Emby 2013 - + -- cgit v1.2.3 From 1a00ac0bbe51f8777bcec0ee9ae12f96468a542b Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 20 Mar 2016 16:04:27 -0400 Subject: update db querying --- MediaBrowser.Api/Reports/ReportsService.cs | 18 ++---------------- MediaBrowser.Api/UserLibrary/ItemsService.cs | 18 ++---------------- MediaBrowser.Controller/Entities/Folder.cs | 12 ++++++------ MediaBrowser.Controller/Entities/InternalItemsQuery.cs | 1 + MediaBrowser.Controller/Entities/UserViewBuilder.cs | 15 +++++++++++++++ 5 files changed, 26 insertions(+), 38 deletions(-) (limited to 'MediaBrowser.Controller/Entities/UserViewBuilder.cs') diff --git a/MediaBrowser.Api/Reports/ReportsService.cs b/MediaBrowser.Api/Reports/ReportsService.cs index 59e969235..4ff3dcf26 100644 --- a/MediaBrowser.Api/Reports/ReportsService.cs +++ b/MediaBrowser.Api/Reports/ReportsService.cs @@ -259,7 +259,8 @@ namespace MediaBrowser.Api.Reports MaxPlayers = request.MaxPlayers, MinCommunityRating = request.MinCommunityRating, MinCriticRating = request.MinCriticRating, - ParentIndexNumber = request.ParentIndexNumber + ParentIndexNumber = request.ParentIndexNumber, + AiredDuringSeason = request.AiredDuringSeason }; if (!string.IsNullOrWhiteSpace(request.Ids)) @@ -487,21 +488,6 @@ namespace MediaBrowser.Api.Reports } } - if (request.AiredDuringSeason.HasValue) - { - var episode = i as Episode; - - if (episode == null) - { - return false; - } - - if (!Series.FilterEpisodesBySeason(new[] { episode }, request.AiredDuringSeason.Value, true).Any()) - { - return false; - } - } - return true; } diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index a48fcbc93..c54f25973 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -232,7 +232,8 @@ namespace MediaBrowser.Api.UserLibrary MinCommunityRating = request.MinCommunityRating, MinCriticRating = request.MinCriticRating, ParentId = string.IsNullOrWhiteSpace(request.ParentId) ? (Guid?)null : new Guid(request.ParentId), - ParentIndexNumber = request.ParentIndexNumber + ParentIndexNumber = request.ParentIndexNumber, + AiredDuringSeason = request.AiredDuringSeason }; if (!string.IsNullOrWhiteSpace(request.Ids)) @@ -445,21 +446,6 @@ namespace MediaBrowser.Api.UserLibrary } } - if (request.AiredDuringSeason.HasValue) - { - var episode = i as Episode; - - if (episode == null) - { - return false; - } - - if (!Series.FilterEpisodesBySeason(new[] { episode }, request.AiredDuringSeason.Value, true).Any()) - { - return false; - } - } - return true; } } diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 5a5fe2a9f..faa5f7dc5 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -1120,12 +1120,6 @@ namespace MediaBrowser.Controller.Entities return true; } - if (query.MinCommunityRating.HasValue) - { - Logger.Debug("Query requires post-filtering due to MinCommunityRating"); - return true; - } - if (query.MinIndexNumber.HasValue) { Logger.Debug("Query requires post-filtering due to MinIndexNumber"); @@ -1204,6 +1198,12 @@ namespace MediaBrowser.Controller.Entities return true; } + if (query.AiredDuringSeason.HasValue) + { + Logger.Debug("Query requires post-filtering due to AiredDuringSeason"); + return true; + } + return false; } diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs index e2b393d4d..2f98ac70d 100644 --- a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs +++ b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs @@ -97,6 +97,7 @@ namespace MediaBrowser.Controller.Entities public int? MinPlayers { get; set; } public int? MaxPlayers { get; set; } public int? MinIndexNumber { get; set; } + public int? AiredDuringSeason { get; set; } public double? MinCriticRating { get; set; } public double? MinCommunityRating { get; set; } diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index c33212619..645e6e37d 100644 --- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs +++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs @@ -1737,6 +1737,21 @@ namespace MediaBrowser.Controller.Entities } } + if (query.AiredDuringSeason.HasValue) + { + var episode = item as Episode; + + if (episode == null) + { + return false; + } + + if (!Series.FilterEpisodesBySeason(new[] { episode }, query.AiredDuringSeason.Value, true).Any()) + { + return false; + } + } + return true; } -- cgit v1.2.3 From 63fe0239e35caec6aba1c5e65581d2d1e7a4e4bd Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 20 Mar 2016 20:15:56 -0400 Subject: update album queries --- MediaBrowser.Api/Reports/ReportsService.cs | 14 ++------------ MediaBrowser.Api/UserLibrary/ItemsService.cs | 14 ++------------ MediaBrowser.Controller/Entities/Folder.cs | 6 ++++++ MediaBrowser.Controller/Entities/InternalItemsQuery.cs | 3 ++- MediaBrowser.Controller/Entities/UserViewBuilder.cs | 11 +++++++++++ 5 files changed, 23 insertions(+), 25 deletions(-) (limited to 'MediaBrowser.Controller/Entities/UserViewBuilder.cs') diff --git a/MediaBrowser.Api/Reports/ReportsService.cs b/MediaBrowser.Api/Reports/ReportsService.cs index 4ff3dcf26..5b492d8b4 100644 --- a/MediaBrowser.Api/Reports/ReportsService.cs +++ b/MediaBrowser.Api/Reports/ReportsService.cs @@ -260,7 +260,8 @@ namespace MediaBrowser.Api.Reports MinCommunityRating = request.MinCommunityRating, MinCriticRating = request.MinCriticRating, ParentIndexNumber = request.ParentIndexNumber, - AiredDuringSeason = request.AiredDuringSeason + AiredDuringSeason = request.AiredDuringSeason, + AlbumArtistStartsWithOrGreater = request.AlbumArtistStartsWithOrGreater }; if (!string.IsNullOrWhiteSpace(request.Ids)) @@ -477,17 +478,6 @@ namespace MediaBrowser.Api.Reports } } - if (!string.IsNullOrEmpty(request.AlbumArtistStartsWithOrGreater)) - { - var ok = new[] { i }.OfType() - .Any(p => string.Compare(request.AlbumArtistStartsWithOrGreater, p.AlbumArtists.FirstOrDefault(), StringComparison.CurrentCultureIgnoreCase) < 1); - - if (!ok) - { - return false; - } - } - return true; } diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index c54f25973..92b2d6002 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -233,7 +233,8 @@ namespace MediaBrowser.Api.UserLibrary MinCriticRating = request.MinCriticRating, ParentId = string.IsNullOrWhiteSpace(request.ParentId) ? (Guid?)null : new Guid(request.ParentId), ParentIndexNumber = request.ParentIndexNumber, - AiredDuringSeason = request.AiredDuringSeason + AiredDuringSeason = request.AiredDuringSeason, + AlbumArtistStartsWithOrGreater = request.AlbumArtistStartsWithOrGreater }; if (!string.IsNullOrWhiteSpace(request.Ids)) @@ -435,17 +436,6 @@ namespace MediaBrowser.Api.UserLibrary } } - if (!string.IsNullOrEmpty(request.AlbumArtistStartsWithOrGreater)) - { - var ok = new[] { i }.OfType() - .Any(p => string.Compare(request.AlbumArtistStartsWithOrGreater, p.AlbumArtists.FirstOrDefault(), StringComparison.CurrentCultureIgnoreCase) < 1); - - if (!ok) - { - return false; - } - } - return true; } } diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index dc0a8d0aa..dcdd10dd6 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -1188,6 +1188,12 @@ namespace MediaBrowser.Controller.Entities return true; } + if (!string.IsNullOrWhiteSpace(query.AlbumArtistStartsWithOrGreater)) + { + Logger.Debug("Query requires post-filtering due to AlbumArtistStartsWithOrGreater"); + return true; + } + return false; } diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs index 2f98ac70d..da76e7db0 100644 --- a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs +++ b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs @@ -125,7 +125,8 @@ namespace MediaBrowser.Controller.Entities public DayOfWeek[] AirDays { get; set; } public SeriesStatus[] SeriesStatuses { get; set; } - + public string AlbumArtistStartsWithOrGreater { get; set; } + public InternalItemsQuery() { BlockUnratedItems = new UnratedItem[] { }; diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index 645e6e37d..ccb842cf4 100644 --- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs +++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs @@ -1752,6 +1752,17 @@ namespace MediaBrowser.Controller.Entities } } + if (!string.IsNullOrEmpty(query.AlbumArtistStartsWithOrGreater)) + { + var ok = new[] { item }.OfType() + .Any(p => string.Compare(query.AlbumArtistStartsWithOrGreater, p.AlbumArtists.FirstOrDefault(), StringComparison.CurrentCultureIgnoreCase) < 1); + + if (!ok) + { + return false; + } + } + return true; } -- cgit v1.2.3 From dfafa98da3ad6d1c2aa982cebd63bd35bba895e0 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 20 Mar 2016 23:14:39 -0400 Subject: fix ExcludeLocationTypes --- MediaBrowser.Controller/Entities/UserViewBuilder.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'MediaBrowser.Controller/Entities/UserViewBuilder.cs') diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index ccb842cf4..ee5412d62 100644 --- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs +++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs @@ -1199,6 +1199,11 @@ namespace MediaBrowser.Controller.Entities return false; } + if (query.ExcludeLocationTypes.Length > 0 && query.ExcludeLocationTypes.Contains(item.LocationType)) + { + return false; + } + if (query.IsFolder.HasValue && query.IsFolder.Value != item.IsFolder) { return false; -- cgit v1.2.3 From 23fe6dc4be28c4d273bb22962ac769c749931090 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 21 Mar 2016 12:50:50 -0400 Subject: update db querying --- MediaBrowser.Api/Reports/ReportsService.cs | 63 +++++----------------- MediaBrowser.Api/UserLibrary/ItemsService.cs | 63 +++++----------------- MediaBrowser.Controller/Entities/Folder.cs | 12 +++++ .../Entities/InternalItemsQuery.cs | 6 +++ .../Entities/UserViewBuilder.cs | 47 ++++++++++++++++ 5 files changed, 89 insertions(+), 102 deletions(-) (limited to 'MediaBrowser.Controller/Entities/UserViewBuilder.cs') diff --git a/MediaBrowser.Api/Reports/ReportsService.cs b/MediaBrowser.Api/Reports/ReportsService.cs index 5dc6e2d84..15bdf4be6 100644 --- a/MediaBrowser.Api/Reports/ReportsService.cs +++ b/MediaBrowser.Api/Reports/ReportsService.cs @@ -350,6 +350,18 @@ namespace MediaBrowser.Api.Reports query.MaxParentalRating = _localization.GetRatingLevel(request.MinOfficialRating); } + // Artists + if (!string.IsNullOrEmpty(request.Artists)) + { + query.ArtistNames = request.Artists.Split('|'); + } + + // Albums + if (!string.IsNullOrEmpty(request.Albums)) + { + query.AlbumNames = request.Albums.Split('|'); + } + if (request.HasQueryLimit == false) { query.StartIndex = null; @@ -378,57 +390,6 @@ namespace MediaBrowser.Api.Reports } } - // Artists - if (!string.IsNullOrEmpty(request.Artists)) - { - var artists = request.Artists.Split('|'); - - var audio = i as IHasArtist; - - if (!(audio != null && artists.Any(audio.HasAnyArtist))) - { - return false; - } - } - - // Albums - if (!string.IsNullOrEmpty(request.Albums)) - { - var albums = request.Albums.Split('|'); - - var audio = i as Audio; - - if (audio != null) - { - if (!albums.Any(a => string.Equals(a, audio.Album, StringComparison.OrdinalIgnoreCase))) - { - return false; - } - } - - var album = i as MusicAlbum; - - if (album != null) - { - if (!albums.Any(a => string.Equals(a, album.Name, StringComparison.OrdinalIgnoreCase))) - { - return false; - } - } - - var musicVideo = i as MusicVideo; - - if (musicVideo != null) - { - if (!albums.Any(a => string.Equals(a, musicVideo.Album, StringComparison.OrdinalIgnoreCase))) - { - return false; - } - } - - return false; - } - return true; } diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index f32165fca..566b1dfd5 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -323,6 +323,18 @@ namespace MediaBrowser.Api.UserLibrary query.MaxParentalRating = _localization.GetRatingLevel(request.MinOfficialRating); } + // Artists + if (!string.IsNullOrEmpty(request.Artists)) + { + query.ArtistNames = request.Artists.Split('|'); + } + + // Albums + if (!string.IsNullOrEmpty(request.Albums)) + { + query.AlbumNames = request.Albums.Split('|'); + } + return query; } @@ -345,57 +357,6 @@ namespace MediaBrowser.Api.UserLibrary } } - // Artists - if (!string.IsNullOrEmpty(request.Artists)) - { - var artists = request.Artists.Split('|'); - - var audio = i as IHasArtist; - - if (!(audio != null && artists.Any(audio.HasAnyArtist))) - { - return false; - } - } - - // Albums - if (!string.IsNullOrEmpty(request.Albums)) - { - var albums = request.Albums.Split('|'); - - var audio = i as Audio; - - if (audio != null) - { - if (!albums.Any(a => string.Equals(a, audio.Album, StringComparison.OrdinalIgnoreCase))) - { - return false; - } - } - - var album = i as MusicAlbum; - - if (album != null) - { - if (!albums.Any(a => string.Equals(a, album.Name, StringComparison.OrdinalIgnoreCase))) - { - return false; - } - } - - var musicVideo = i as MusicVideo; - - if (musicVideo != null) - { - if (!albums.Any(a => string.Equals(a, musicVideo.Album, StringComparison.OrdinalIgnoreCase))) - { - return false; - } - } - - return false; - } - return true; } } diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index d2fa5d9a0..fa96ba4e5 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -1175,6 +1175,18 @@ namespace MediaBrowser.Controller.Entities return true; } + if (query.AlbumNames.Length > 0) + { + Logger.Debug("Query requires post-filtering due to AlbumNames"); + return true; + } + + if (query.ArtistNames.Length > 0) + { + Logger.Debug("Query requires post-filtering due to ArtistNames"); + return true; + } + return false; } diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs index e98c89abf..b568aec18 100644 --- a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs +++ b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs @@ -128,8 +128,14 @@ namespace MediaBrowser.Controller.Entities public SeriesStatus[] SeriesStatuses { get; set; } public string AlbumArtistStartsWithOrGreater { get; set; } + public string[] AlbumNames { get; set; } + public string[] ArtistNames { get; set; } + public InternalItemsQuery() { + AlbumNames = new string[] { }; + ArtistNames = new string[] { }; + BlockUnratedItems = new UnratedItem[] { }; Tags = new string[] { }; OfficialRatings = new string[] { }; diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index ee5412d62..a74859a46 100644 --- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs +++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs @@ -1768,6 +1768,53 @@ namespace MediaBrowser.Controller.Entities } } + // Artists + if (query.ArtistNames.Length > 0) + { + var audio = item as IHasArtist; + + if (!(audio != null && query.ArtistNames.Any(audio.HasAnyArtist))) + { + return false; + } + } + + // Albums + if (query.AlbumNames.Length > 0) + { + var audio = item as Audio.Audio; + + if (audio != null) + { + if (!query.AlbumNames.Any(a => string.Equals(a, audio.Album, StringComparison.OrdinalIgnoreCase))) + { + return false; + } + } + + var album = item as MusicAlbum; + + if (album != null) + { + if (!query.AlbumNames.Any(a => string.Equals(a, album.Name, StringComparison.OrdinalIgnoreCase))) + { + return false; + } + } + + var musicVideo = item as MusicVideo; + + if (musicVideo != null) + { + if (!query.AlbumNames.Any(a => string.Equals(a, musicVideo.Album, StringComparison.OrdinalIgnoreCase))) + { + return false; + } + } + + return false; + } + return true; } -- cgit v1.2.3