Renamed watched to played (since we support audio)

This commit is contained in:
LukePulverenti Luke Pulverenti luke pulverenti 2012-08-19 13:00:52 -04:00
parent 874469d476
commit f392de9b69
5 changed files with 16 additions and 7 deletions

View File

@ -38,6 +38,7 @@ namespace MediaBrowser.Api
dto.HasPrimaryImage = !string.IsNullOrEmpty(item.LogoImagePath); dto.HasPrimaryImage = !string.IsNullOrEmpty(item.LogoImagePath);
dto.HasThumb = !string.IsNullOrEmpty(item.ThumbnailImagePath); dto.HasThumb = !string.IsNullOrEmpty(item.ThumbnailImagePath);
dto.Id = item.Id; dto.Id = item.Id;
dto.IsRecentlyAdded = item.IsRecentlyAdded(user);
dto.IndexNumber = item.IndexNumber; dto.IndexNumber = item.IndexNumber;
dto.IsFolder = item is Folder; dto.IsFolder = item is Folder;
dto.LocalTrailerCount = item.LocalTrailers == null ? 0 : item.LocalTrailers.Count(); dto.LocalTrailerCount = item.LocalTrailers == null ? 0 : item.LocalTrailers.Count();

View File

@ -96,5 +96,7 @@ namespace MediaBrowser.Model.DTO
{ {
return Type.Equals(type, StringComparison.OrdinalIgnoreCase); return Type.Equals(type, StringComparison.OrdinalIgnoreCase);
} }
public bool IsRecentlyAdded { get; set; }
} }
} }

View File

@ -130,5 +130,13 @@ namespace MediaBrowser.Model.Entities
return null; return null;
} }
/// <summary>
/// Determines if the item is considered new based on user settings
/// </summary>
public bool IsRecentlyAdded(User user)
{
return (DateTime.Now - DateCreated).TotalDays < user.RecentItemDays;
}
} }
} }

View File

@ -51,7 +51,7 @@ namespace MediaBrowser.Model.Entities
counts.RecentlyAddedItemCount = GetRecentlyAddedItems(recursiveChildren, user).Count(); counts.RecentlyAddedItemCount = GetRecentlyAddedItems(recursiveChildren, user).Count();
counts.RecentlyAddedUnPlayedItemCount = GetRecentlyAddedUnplayedItems(recursiveChildren, user).Count(); counts.RecentlyAddedUnPlayedItemCount = GetRecentlyAddedUnplayedItems(recursiveChildren, user).Count();
counts.InProgressItemCount = GetInProgressItems(recursiveChildren, user).Count(); counts.InProgressItemCount = GetInProgressItems(recursiveChildren, user).Count();
counts.WatchedPercentage = GetWatchedPercentage(recursiveChildren, user); counts.PlayedPercentage = GetPlayedPercentage(recursiveChildren, user);
return counts; return counts;
} }
@ -139,9 +139,7 @@ namespace MediaBrowser.Model.Entities
private static IEnumerable<BaseItem> GetRecentlyAddedItems(IEnumerable<BaseItem> itemSet, User user) private static IEnumerable<BaseItem> GetRecentlyAddedItems(IEnumerable<BaseItem> itemSet, User user)
{ {
DateTime now = DateTime.Now; return itemSet.Where(i => !(i is Folder) && i.IsRecentlyAdded(user));
return itemSet.Where(i => !(i is Folder) && (now - i.DateCreated).TotalDays < user.RecentItemDays);
} }
private static IEnumerable<BaseItem> GetRecentlyAddedUnplayedItems(IEnumerable<BaseItem> itemSet, User user) private static IEnumerable<BaseItem> GetRecentlyAddedUnplayedItems(IEnumerable<BaseItem> itemSet, User user)
@ -169,7 +167,7 @@ namespace MediaBrowser.Model.Entities
}); });
} }
private static decimal GetWatchedPercentage(IEnumerable<BaseItem> itemSet, User user) private static decimal GetPlayedPercentage(IEnumerable<BaseItem> itemSet, User user)
{ {
itemSet = itemSet.Where(i => !(i is Folder)); itemSet = itemSet.Where(i => !(i is Folder));

View File

@ -9,6 +9,6 @@ namespace MediaBrowser.Model.Entities
public int RecentlyAddedItemCount { get; set; } public int RecentlyAddedItemCount { get; set; }
public int RecentlyAddedUnPlayedItemCount { get; set; } public int RecentlyAddedUnPlayedItemCount { get; set; }
public int InProgressItemCount { get; set; } public int InProgressItemCount { get; set; }
public decimal WatchedPercentage { get; set; } public decimal PlayedPercentage { get; set; }
} }
} }