fixes #541 - ItemQuery returns incorrect UserData

This commit is contained in:
Luke Pulverenti 2013-09-23 10:26:20 -04:00
parent b54240f679
commit 28e788e435
6 changed files with 21 additions and 31 deletions

View File

@ -45,7 +45,7 @@ namespace MediaBrowser.Api
/// Fields to return within the items, in addition to basic information /// Fields to return within the items, in addition to basic information
/// </summary> /// </summary>
/// <value>The fields.</value> /// <value>The fields.</value>
[ApiMember(Name = "Fields", Description = "Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: Budget, Chapters, CriticRatingSummary, DateCreated, Genres, HomePageUrl, ItemCounts, IndexOptions, MediaStreams, Overview, OverviewHtml, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines, TrailerUrls", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] [ApiMember(Name = "Fields", Description = "Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: Budget, Chapters, CriticRatingSummary, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, OverviewHtml, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines, TrailerUrls", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
public string Fields { get; set; } public string Fields { get; set; }
/// <summary> /// <summary>

View File

@ -43,7 +43,7 @@ namespace MediaBrowser.Api
/// Fields to return within the items, in addition to basic information /// Fields to return within the items, in addition to basic information
/// </summary> /// </summary>
/// <value>The fields.</value> /// <value>The fields.</value>
[ApiMember(Name = "Fields", Description = "Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: Budget, Chapters, CriticRatingSummary, DateCreated, Genres, HomePageUrl, ItemCounts, IndexOptions, MediaStreams, Overview, OverviewHtml, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines, TrailerUrls", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] [ApiMember(Name = "Fields", Description = "Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: Budget, Chapters, CriticRatingSummary, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, OverviewHtml, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines, TrailerUrls", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
public string Fields { get; set; } public string Fields { get; set; }
/// <summary> /// <summary>

View File

@ -48,7 +48,7 @@ namespace MediaBrowser.Api.UserLibrary
/// Fields to return within the items, in addition to basic information /// Fields to return within the items, in addition to basic information
/// </summary> /// </summary>
/// <value>The fields.</value> /// <value>The fields.</value>
[ApiMember(Name = "Fields", Description = "Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: Budget, Chapters, CriticRatingSummary, DateCreated, Genres, HomePageUrl, ItemCounts, IndexOptions, MediaStreams, Overview, OverviewHtml, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines, TrailerUrls", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] [ApiMember(Name = "Fields", Description = "Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: Budget, Chapters, CriticRatingSummary, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, OverviewHtml, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines, TrailerUrls", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
public string Fields { get; set; } public string Fields { get; set; }
/// <summary> /// <summary>

View File

@ -51,11 +51,6 @@ namespace MediaBrowser.Model.Querying
/// </summary> /// </summary>
HomePageUrl, HomePageUrl,
/// <summary>
/// Child count, recursive child count, etc
/// </summary>
ItemCounts,
/// <summary> /// <summary>
/// The fields that the server supports indexing on /// The fields that the server supports indexing on
/// </summary> /// </summary>

View File

@ -107,14 +107,11 @@ namespace MediaBrowser.Server.Implementations.Dto
.ToArray(); .ToArray();
} }
if (fields.Contains(ItemFields.ItemCounts))
{
var itemByName = item as IItemByName; var itemByName = item as IItemByName;
if (itemByName != null) if (itemByName != null)
{ {
AttachItemByNameCounts(dto, itemByName, user); AttachItemByNameCounts(dto, itemByName, user);
} }
}
return dto; return dto;
} }
@ -165,19 +162,14 @@ namespace MediaBrowser.Server.Implementations.Dto
private void AttachUserSpecificInfo(BaseItemDto dto, BaseItem item, User user, List<ItemFields> fields) private void AttachUserSpecificInfo(BaseItemDto dto, BaseItem item, User user, List<ItemFields> fields)
{ {
if (item.IsFolder) if (item.IsFolder)
{
var hasItemCounts = fields.Contains(ItemFields.ItemCounts);
if (hasItemCounts || fields.Contains(ItemFields.CumulativeRunTimeTicks))
{ {
var folder = (Folder)item; var folder = (Folder)item;
if (hasItemCounts)
{
dto.ChildCount = folder.GetChildren(user, true).Count(); dto.ChildCount = folder.GetChildren(user, true).Count();
}
SetSpecialCounts(folder, user, dto); if (!(folder is UserRootFolder))
{
SetSpecialCounts(folder, user, dto, fields);
} }
} }
@ -1068,8 +1060,9 @@ namespace MediaBrowser.Server.Implementations.Dto
/// <param name="folder">The folder.</param> /// <param name="folder">The folder.</param>
/// <param name="user">The user.</param> /// <param name="user">The user.</param>
/// <param name="dto">The dto.</param> /// <param name="dto">The dto.</param>
/// <param name="fields">The fields.</param>
/// <returns>Task.</returns> /// <returns>Task.</returns>
private void SetSpecialCounts(Folder folder, User user, BaseItemDto dto) private void SetSpecialCounts(Folder folder, User user, BaseItemDto dto, List<ItemFields> fields)
{ {
var rcentlyAddedItemCount = 0; var rcentlyAddedItemCount = 0;
var recursiveItemCount = 0; var recursiveItemCount = 0;
@ -1127,7 +1120,7 @@ namespace MediaBrowser.Server.Implementations.Dto
dto.PlayedPercentage = totalPercentPlayed / recursiveItemCount; dto.PlayedPercentage = totalPercentPlayed / recursiveItemCount;
} }
if (runtime > 0) if (runtime > 0 && fields.Contains(ItemFields.CumulativeRunTimeTicks))
{ {
dto.CumulativeRunTimeTicks = runtime; dto.CumulativeRunTimeTicks = runtime;
} }

View File

@ -356,6 +356,12 @@ namespace MediaBrowser.Server.Implementations.HttpServer
try try
{ {
ProcessRequest(context); ProcessRequest(context);
var url = context.Request.Url.ToString();
var endPoint = context.Request.RemoteEndPoint;
LogResponse(context, url, endPoint);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -433,9 +439,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer
var httpRes = new HttpListenerResponseWrapper(context.Response); var httpRes = new HttpListenerResponseWrapper(context.Response);
var handler = ServiceStackHttpHandlerFactory.GetHandler(httpReq); var handler = ServiceStackHttpHandlerFactory.GetHandler(httpReq);
var url = context.Request.Url.ToString();
var endPoint = context.Request.RemoteEndPoint;
var serviceStackHandler = handler as IServiceStackHttpHandler; var serviceStackHandler = handler as IServiceStackHttpHandler;
if (serviceStackHandler != null) if (serviceStackHandler != null)
@ -446,7 +449,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer
httpReq.OperationName = operationName = restHandler.RestPath.RequestType.Name; httpReq.OperationName = operationName = restHandler.RestPath.RequestType.Name;
} }
serviceStackHandler.ProcessRequest(httpReq, httpRes, operationName); serviceStackHandler.ProcessRequest(httpReq, httpRes, operationName);
LogResponse(context, url, endPoint);
return; return;
} }
@ -529,7 +531,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
{ {
new ClientWebSocket(); new ClientWebSocket();
_supportsNativeWebSocket = true; _supportsNativeWebSocket = false;
} }
catch (PlatformNotSupportedException) catch (PlatformNotSupportedException)
{ {