Merge pull request #2065 from MediaBrowser/dev

update season queries
This commit is contained in:
Luke 2016-08-16 13:09:03 -04:00 committed by GitHub
commit de578f7e40
6 changed files with 44 additions and 17 deletions

View File

@ -490,7 +490,7 @@ namespace MediaBrowser.Api
}
else
{
episodes = series.GetEpisodes(user, season);
episodes = series.GetSeasonEpisodes(user, season);
}
}
else

View File

@ -13,6 +13,7 @@ using System.Threading;
using System.Threading.Tasks;
using CommonIO;
using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Model.Channels;
@ -1427,7 +1428,7 @@ namespace MediaBrowser.Controller.Entities
itemDto.RecursiveItemCount = allItemsQueryResult.TotalRecordCount;
}
double recursiveItemCount = allItemsQueryResult.TotalRecordCount;
var recursiveItemCount = allItemsQueryResult.TotalRecordCount;
double unplayedCount = unplayedQueryResult.TotalRecordCount;
if (recursiveItemCount > 0)
@ -1437,6 +1438,14 @@ namespace MediaBrowser.Controller.Entities
dto.Played = dto.PlayedPercentage.Value >= 100;
dto.UnplayedItemCount = unplayedQueryResult.TotalRecordCount;
}
if (itemDto != null)
{
if (this is Season || this is MusicAlbum)
{
itemDto.ChildCount = recursiveItemCount;
}
}
}
}
}

View File

@ -85,7 +85,11 @@ namespace MediaBrowser.Controller.Entities.TV
public override int GetChildCount(User user)
{
return GetChildren(user, true).Count();
Logger.Debug("Season {0} getting child cound", (Path ?? Name));
var result = GetChildren(user, true).Count();
Logger.Debug("Season {0} child cound: ", result);
return result;
}
/// <summary>
@ -192,7 +196,7 @@ namespace MediaBrowser.Controller.Entities.TV
public IEnumerable<Episode> GetEpisodes(Series series, User user, bool includeMissingEpisodes, bool includeVirtualUnairedEpisodes, IEnumerable<Episode> allSeriesEpisodes)
{
return series.GetEpisodes(user, this, includeMissingEpisodes, includeVirtualUnairedEpisodes, allSeriesEpisodes);
return series.GetSeasonEpisodes(user, this, includeMissingEpisodes, includeVirtualUnairedEpisodes, allSeriesEpisodes);
}
public IEnumerable<Episode> GetEpisodes()

View File

@ -254,19 +254,16 @@ namespace MediaBrowser.Controller.Entities.TV
}).Cast<Season>().ToList();
Logger.Debug("GetSeasons returned {0} items from database", seasons.Count);
if (!includeMissingSeasons)
{
seasons = seasons.Where(i => !(i.IsMissingSeason)).ToList();
}
Logger.Debug("GetSeasons has {0} items after includeMissingSeasons filter", seasons.Count);
if (!includeVirtualUnaired)
{
seasons = seasons.Where(i => !i.IsVirtualUnaired).ToList();
}
Logger.Debug("GetSeasons has {0} items after includeVirtualUnaired filter", seasons.Count);
return seasons;
}
@ -280,14 +277,19 @@ namespace MediaBrowser.Controller.Entities.TV
public IEnumerable<Episode> GetEpisodes(User user, bool includeMissing, bool includeVirtualUnaired)
{
var seriesKey = GetUniqueSeriesKey(this);
Logger.Debug("GetEpisodes seriesKey: {0}", seriesKey);
var allItems = LibraryManager.GetItemList(new InternalItemsQuery(user)
{
AncestorWithPresentationUniqueKey = GetUniqueSeriesKey(this),
AncestorWithPresentationUniqueKey = seriesKey,
IncludeItemTypes = new[] { typeof(Episode).Name, typeof(Season).Name },
SortBy = new[] { ItemSortBy.SortName }
}).ToList();
Logger.Debug("GetEpisodes return {0} items from database", allItems.Count);
var allSeriesEpisodes = allItems.OfType<Episode>().ToList();
var allEpisodes = allItems.OfType<Season>()
@ -368,11 +370,11 @@ namespace MediaBrowser.Controller.Entities.TV
progress.Report(100);
}
public IEnumerable<Episode> GetEpisodes(User user, Season season)
public IEnumerable<Episode> GetSeasonEpisodes(User user, Season season)
{
var config = user.Configuration;
return GetEpisodes(user, season, config.DisplayMissingEpisodes, config.DisplayUnairedEpisodes);
return GetSeasonEpisodes(user, season, config.DisplayMissingEpisodes, config.DisplayUnairedEpisodes);
}
private IEnumerable<Episode> GetAllEpisodes(User user)
@ -386,20 +388,22 @@ namespace MediaBrowser.Controller.Entities.TV
}).Cast<Episode>();
}
public IEnumerable<Episode> GetEpisodes(User user, Season parentSeason, bool includeMissingEpisodes, bool includeVirtualUnairedEpisodes)
public IEnumerable<Episode> GetSeasonEpisodes(User user, Season parentSeason, bool includeMissingEpisodes, bool includeVirtualUnairedEpisodes)
{
IEnumerable<Episode> episodes = GetAllEpisodes(user);
return GetEpisodes(user, parentSeason, includeMissingEpisodes, includeVirtualUnairedEpisodes, episodes);
return GetSeasonEpisodes(user, parentSeason, includeMissingEpisodes, includeVirtualUnairedEpisodes, episodes);
}
public IEnumerable<Episode> GetEpisodes(User user, Season parentSeason, bool includeMissingEpisodes, bool includeVirtualUnairedEpisodes, IEnumerable<Episode> allSeriesEpisodes)
public IEnumerable<Episode> GetSeasonEpisodes(User user, Season parentSeason, bool includeMissingEpisodes, bool includeVirtualUnairedEpisodes, IEnumerable<Episode> allSeriesEpisodes)
{
if (allSeriesEpisodes == null)
{
return GetEpisodes(user, parentSeason, includeMissingEpisodes, includeVirtualUnairedEpisodes);
Logger.Debug("GetSeasonEpisodes allSeriesEpisodes is null");
return GetSeasonEpisodes(user, parentSeason, includeMissingEpisodes, includeVirtualUnairedEpisodes);
}
Logger.Debug("GetSeasonEpisodes FilterEpisodesBySeason");
var episodes = FilterEpisodesBySeason(allSeriesEpisodes, parentSeason, ConfigurationManager.Configuration.DisplaySpecialsWithinSeasons);
if (!includeMissingEpisodes)

View File

@ -458,7 +458,7 @@ namespace MediaBrowser.Server.Implementations.Dto
dto.UserData = await _userDataRepository.GetUserDataDto(item, dto, user).ConfigureAwait(false);
if (item.SourceType == SourceType.Library)
if (!dto.ChildCount.HasValue && item.SourceType == SourceType.Library)
{
dto.ChildCount = GetChildCount(folder, user);
}

View File

@ -38,7 +38,6 @@ namespace MediaBrowser.Server.Implementations.IO
/// </summary>
private readonly IReadOnlyList<string> _alwaysIgnoreFiles = new List<string>
{
"thumbs.db",
"small.jpg",
"albumart.jpg",
@ -47,6 +46,15 @@ namespace MediaBrowser.Server.Implementations.IO
"TempSBE"
};
private readonly IReadOnlyList<string> _alwaysIgnoreExtensions = new List<string>
{
// thumbs.db
".db",
// bts sync files
".bts"
};
/// <summary>
/// Add the path to our temporary ignore list. Use when writing to a path within our listening scope.
/// </summary>
@ -411,7 +419,9 @@ namespace MediaBrowser.Server.Implementations.IO
var filename = Path.GetFileName(path);
var monitorPath = !(!string.IsNullOrEmpty(filename) && _alwaysIgnoreFiles.Contains(filename, StringComparer.OrdinalIgnoreCase));
var monitorPath = !string.IsNullOrEmpty(filename) &&
!_alwaysIgnoreFiles.Contains(filename, StringComparer.OrdinalIgnoreCase) &&
!_alwaysIgnoreExtensions.Contains(Path.GetExtension(path) ?? string.Empty, StringComparer.OrdinalIgnoreCase);
// Ignore certain files
var tempIgnorePaths = _tempIgnoredPaths.Keys.ToList();