update pooling
This commit is contained in:
parent
437033111c
commit
66c86ccc58
|
@ -35,7 +35,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
|||
public static void LogResponse(ILogger logger, int statusCode, string url, string endPoint, TimeSpan duration)
|
||||
{
|
||||
var durationMs = duration.TotalMilliseconds;
|
||||
var logSuffix = durationMs >= 1000 ? "ms (slow)" : "ms";
|
||||
var logSuffix = durationMs >= 1000 && durationMs < 60000 ? "ms (slow)" : "ms";
|
||||
|
||||
logger.Info("HTTP Response {0} to {1}. Time: {2}{3}. {4}", statusCode, endPoint, Convert.ToInt32(durationMs).ToString(CultureInfo.InvariantCulture), logSuffix, url);
|
||||
}
|
||||
|
|
|
@ -45,6 +45,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
|
|||
|
||||
private async Task<string> GetXml(string path, CancellationToken cancellationToken)
|
||||
{
|
||||
_logger.Info("xmltv path: {0}", path);
|
||||
|
||||
if (!path.StartsWith("http", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return path;
|
||||
|
@ -161,7 +163,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
|
|||
{
|
||||
Id = c.Id,
|
||||
Name = c.DisplayName,
|
||||
ImageUrl = c.Icon != null && !String.IsNullOrEmpty(c.Icon.Source) ? c.Icon.Source : null
|
||||
ImageUrl = c.Icon != null && !String.IsNullOrEmpty(c.Icon.Source) ? c.Icon.Source : null,
|
||||
Number = c.Id
|
||||
|
||||
}).ToList();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
JournalMode = SQLiteJournalModeEnum.Wal,
|
||||
|
||||
// This is causing crashing under linux
|
||||
Pooling = Environment.OSVersion.Platform == PlatformID.Win32NT,
|
||||
Pooling = enablePooling && Environment.OSVersion.Platform == PlatformID.Win32NT,
|
||||
ReadOnly = isReadOnly
|
||||
};
|
||||
|
||||
|
|
|
@ -124,58 +124,77 @@ namespace MediaBrowser.Server.Implementations.TV
|
|||
/// <returns>Task{Episode}.</returns>
|
||||
private Tuple<Episode, DateTime, bool> GetNextUp(Series series, User user)
|
||||
{
|
||||
// Get them in display order, then reverse
|
||||
var allEpisodes = series.GetEpisodes(user, false, false)
|
||||
.Where(i => !i.ParentIndexNumber.HasValue || i.ParentIndexNumber.Value != 0)
|
||||
.Reverse()
|
||||
.ToList();
|
||||
|
||||
Episode lastWatched = null;
|
||||
var lastWatchedDate = DateTime.MinValue;
|
||||
Episode nextUp = null;
|
||||
|
||||
var unplayedEpisodes = new List<Episode>();
|
||||
|
||||
// Go back starting with the most recent episodes
|
||||
foreach (var episode in allEpisodes)
|
||||
var firstUnwatchedEpisode = _libraryManager.GetItemList(new InternalItemsQuery(user)
|
||||
{
|
||||
var userData = _userDataManager.GetUserData(user, episode);
|
||||
AncestorWithPresentationUniqueKey = series.PresentationUniqueKey,
|
||||
IncludeItemTypes = new[] { typeof(Episode).Name },
|
||||
SortBy = new[] { ItemSortBy.SortName },
|
||||
SortOrder = SortOrder.Ascending,
|
||||
Limit = 1,
|
||||
IsPlayed = false,
|
||||
IsVirtualItem = false
|
||||
|
||||
if (userData.Played)
|
||||
{
|
||||
if (lastWatched != null || nextUp == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}).Cast<Episode>().FirstOrDefault();
|
||||
|
||||
lastWatched = episode;
|
||||
lastWatchedDate = userData.LastPlayedDate ?? DateTime.MinValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
unplayedEpisodes.Add(episode);
|
||||
|
||||
nextUp = episode;
|
||||
}
|
||||
if (firstUnwatchedEpisode == null)
|
||||
{
|
||||
return new Tuple<Episode, DateTime, bool>(null, DateTime.MinValue, true);
|
||||
}
|
||||
|
||||
if (lastWatched != null)
|
||||
var lastWatchedEpisode = _libraryManager.GetItemList(new InternalItemsQuery(user)
|
||||
{
|
||||
return new Tuple<Episode, DateTime, bool>(nextUp, lastWatchedDate, false);
|
||||
}
|
||||
AncestorWithPresentationUniqueKey = series.PresentationUniqueKey,
|
||||
IncludeItemTypes = new[] { typeof(Episode).Name },
|
||||
SortBy = new[] { ItemSortBy.DatePlayed },
|
||||
SortOrder = SortOrder.Descending,
|
||||
Limit = 1,
|
||||
IsVirtualItem = false
|
||||
|
||||
Episode firstEpisode = null;
|
||||
// Find the first unplayed episode. Start from the back of the list since they're in reverse order
|
||||
for (var i = unplayedEpisodes.Count - 1; i >= 0; i--)
|
||||
}).FirstOrDefault();
|
||||
|
||||
//// Get them in display order, then reverse
|
||||
//var allEpisodes = series.GetEpisodes(user, false, false)
|
||||
// .Where(i => !i.ParentIndexNumber.HasValue || i.ParentIndexNumber.Value != 0)
|
||||
// .Reverse()
|
||||
// .ToList();
|
||||
|
||||
//Episode lastWatched = null;
|
||||
//var lastWatchedDate = DateTime.MinValue;
|
||||
//Episode nextUp = null;
|
||||
|
||||
//// Go back starting with the most recent episodes
|
||||
//foreach (var episode in allEpisodes)
|
||||
//{
|
||||
// var userData = _userDataManager.GetUserData(user, episode);
|
||||
|
||||
// if (userData.Played)
|
||||
// {
|
||||
// if (lastWatched != null || nextUp == null)
|
||||
// {
|
||||
// break;
|
||||
// }
|
||||
|
||||
// lastWatched = episode;
|
||||
// lastWatchedDate = userData.LastPlayedDate ?? DateTime.MinValue;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// nextUp = episode;
|
||||
// }
|
||||
//}
|
||||
|
||||
if (lastWatchedEpisode != null)
|
||||
{
|
||||
var unplayedEpisode = unplayedEpisodes[i];
|
||||
var userData = _userDataManager.GetUserData(user, lastWatchedEpisode);
|
||||
|
||||
firstEpisode = unplayedEpisode;
|
||||
break;
|
||||
if (userData.LastPlayedDate.HasValue)
|
||||
{
|
||||
return new Tuple<Episode, DateTime, bool>(firstUnwatchedEpisode, userData.LastPlayedDate.Value, false);
|
||||
}
|
||||
}
|
||||
|
||||
// Return the first episode
|
||||
return new Tuple<Episode, DateTime, bool>(firstEpisode, DateTime.MinValue, true);
|
||||
return new Tuple<Episode, DateTime, bool>(firstUnwatchedEpisode, DateTime.MinValue, true);
|
||||
}
|
||||
|
||||
private QueryResult<BaseItem> GetResult(IEnumerable<BaseItem> items, int? totalRecordLimit, NextUpQuery query)
|
||||
|
|
Loading…
Reference in New Issue
Block a user