From 326fa5a67090246c519cdb318c314bee4049a460 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 10 Feb 2014 13:43:33 -0500 Subject: [PATCH] Added date last media added --- .../Dto/DtoService.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index 5fa96c34b7..2584fa4f0a 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -1213,6 +1213,7 @@ namespace MediaBrowser.Server.Implementations.Dto var unplayed = 0; long runtime = 0; + DateTime? dateLastMediaAdded = null; double totalPercentPlayed = 0; IEnumerable children; @@ -1231,6 +1232,15 @@ namespace MediaBrowser.Server.Implementations.Dto // Loop through each recursive child foreach (var child in children) { + if (!dateLastMediaAdded.HasValue) + { + dateLastMediaAdded = child.DateCreated; + } + else + { + dateLastMediaAdded = new[] { dateLastMediaAdded.Value, child.DateCreated }.Max(); + } + var userdata = _userDataRepository.GetUserData(user.Id, child.GetUserDataKey()); recursiveItemCount++; @@ -1281,6 +1291,11 @@ namespace MediaBrowser.Server.Implementations.Dto { dto.CumulativeRunTimeTicks = runtime; } + + if (fields.Contains(ItemFields.DateLastMediaAdded)) + { + dto.DateLastMediaAdded = dateLastMediaAdded; + } } ///