Skip to content

Commit

Permalink
pass requested fields to data layer
Browse files Browse the repository at this point in the history
  • Loading branch information
LukePulverenti committed Oct 8, 2016
1 parent 1591b16 commit 5cd3276
Show file tree
Hide file tree
Showing 64 changed files with 739 additions and 633 deletions.
4 changes: 3 additions & 1 deletion MediaBrowser.Api/FilterService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using MediaBrowser.Model.Querying;
using ServiceStack;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

Expand Down Expand Up @@ -104,7 +105,8 @@ private InternalItemsQuery GetItemsQuery(GetQueryFilters request, User user)
MediaTypes = request.GetMediaTypes(),
IncludeItemTypes = request.GetIncludeItemTypes(),
Recursive = true,
EnableTotalRecordCount = false
EnableTotalRecordCount = false,
Fields = new List<ItemFields> { ItemFields.Genres, ItemFields.Tags }
};

return query;
Expand Down
7 changes: 4 additions & 3 deletions MediaBrowser.Api/GamesService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,19 +200,20 @@ private async Task<QueryResult<BaseItemDto>> GetSimilarItemsResult(BaseGetSimila
(!string.IsNullOrWhiteSpace(request.UserId) ? user.RootFolder :
_libraryManager.RootFolder) : _libraryManager.GetItemById(request.Id);

var dtoOptions = GetDtoOptions(request);

var itemsResult = _libraryManager.GetItemList(new InternalItemsQuery(user)
{
Limit = request.Limit,
IncludeItemTypes = new[]
{
typeof(Game).Name
},
SimilarTo = item
SimilarTo = item,
Fields = dtoOptions.Fields

}).ToList();

var dtoOptions = GetDtoOptions(request);

var result = new QueryResult<BaseItemDto>
{
Items = (await _dtoService.GetBaseItemDtos(itemsResult, dtoOptions, user).ConfigureAwait(false)).ToArray(),
Expand Down
25 changes: 2 additions & 23 deletions MediaBrowser.Api/ItemUpdateService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,9 @@ private void UpdateItem(BaseItemDto request, BaseItem item)

item.Tags = request.Tags;

var hasTaglines = item as IHasTaglines;
if (hasTaglines != null)
if (request.Taglines != null)
{
hasTaglines.Taglines = request.Taglines;
item.Tagline = request.Taglines.FirstOrDefault();
}

var hasShortOverview = item as IHasShortOverview;
Expand All @@ -304,8 +303,6 @@ private void UpdateItem(BaseItemDto request, BaseItem item)
item.OfficialRating = string.IsNullOrWhiteSpace(request.OfficialRating) ? null : request.OfficialRating;
item.CustomRating = request.CustomRating;

SetProductionLocations(item, request);

item.PreferredMetadataCountryCode = request.PreferredMetadataCountryCode;
item.PreferredMetadataLanguage = request.PreferredMetadataLanguage;

Expand Down Expand Up @@ -413,23 +410,5 @@ private void UpdateItem(BaseItemDto request, BaseItem item)
series.AirTime = request.AirTime;
}
}

private void SetProductionLocations(BaseItem item, BaseItemDto request)
{
var hasProductionLocations = item as IHasProductionLocations;

if (hasProductionLocations != null)
{
hasProductionLocations.ProductionLocations = request.ProductionLocations;
}

var person = item as Person;
if (person != null)
{
person.PlaceOfBirth = request.ProductionLocations == null
? null
: request.ProductionLocations.FirstOrDefault();
}
}
}
}
5 changes: 3 additions & 2 deletions MediaBrowser.Api/MediaBrowser.Api.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand All @@ -11,9 +11,10 @@
<AssemblyName>MediaBrowser.Api</AssemblyName>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<ReleaseVersion>
</ReleaseVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
22 changes: 14 additions & 8 deletions MediaBrowser.Api/Movies/MoviesService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,18 +156,19 @@ private async Task<QueryResult<BaseItemDto>> GetSimilarItemsResult(BaseGetSimila
itemTypes.Add(typeof(LiveTvProgram).Name);
}

var dtoOptions = GetDtoOptions(request);

var itemsResult = _libraryManager.GetItemList(new InternalItemsQuery(user)
{
Limit = request.Limit,
IncludeItemTypes = itemTypes.ToArray(),
IsMovie = true,
SimilarTo = item,
EnableGroupByMetadataKey = true
EnableGroupByMetadataKey = true,
Fields = dtoOptions.Fields

}).ToList();

var dtoOptions = GetDtoOptions(request);

var result = new QueryResult<BaseItemDto>
{
Items = (await _dtoService.GetBaseItemDtos(itemsResult, dtoOptions, user).ConfigureAwait(false)).ToArray(),
Expand Down Expand Up @@ -198,7 +199,8 @@ private IEnumerable<RecommendationDto> GetRecommendationCategories(User user, st
Limit = 7,
ParentId = parentIdGuid,
Recursive = true,
IsPlayed = true
IsPlayed = true,
Fields = dtoOptions.Fields
};

var recentlyPlayedMovies = _libraryManager.GetItemList(query).ToList();
Expand All @@ -221,7 +223,8 @@ private IEnumerable<RecommendationDto> GetRecommendationCategories(User user, st
ExcludeItemIds = recentlyPlayedMovies.Select(i => i.Id.ToString("N")).ToArray(),
EnableGroupByMetadataKey = true,
ParentId = parentIdGuid,
Recursive = true
Recursive = true,
Fields = dtoOptions.Fields

}).ToList();

Expand Down Expand Up @@ -302,7 +305,8 @@ private IEnumerable<RecommendationDto> GetWithDirector(User user, IEnumerable<st
PersonTypes = new[] { PersonType.Director },
IncludeItemTypes = itemTypes.ToArray(),
IsMovie = true,
EnableGroupByMetadataKey = true
EnableGroupByMetadataKey = true,
Fields = dtoOptions.Fields

}).DistinctBy(i => i.GetProviderId(MetadataProviders.Imdb) ?? Guid.NewGuid().ToString("N"))
.Take(itemLimit)
Expand Down Expand Up @@ -339,7 +343,8 @@ private IEnumerable<RecommendationDto> GetWithActor(User user, IEnumerable<strin
Limit = itemLimit + 2,
IncludeItemTypes = itemTypes.ToArray(),
IsMovie = true,
EnableGroupByMetadataKey = true
EnableGroupByMetadataKey = true,
Fields = dtoOptions.Fields

}).DistinctBy(i => i.GetProviderId(MetadataProviders.Imdb) ?? Guid.NewGuid().ToString("N"))
.Take(itemLimit)
Expand Down Expand Up @@ -375,7 +380,8 @@ private IEnumerable<RecommendationDto> GetSimilarTo(User user, List<BaseItem> ba
IncludeItemTypes = itemTypes.ToArray(),
IsMovie = true,
SimilarTo = item,
EnableGroupByMetadataKey = true
EnableGroupByMetadataKey = true,
Fields = dtoOptions.Fields

}).ToList();

Expand Down
8 changes: 4 additions & 4 deletions MediaBrowser.Api/PackageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class GetPackages : IReturn<List<PackageInfo>>
/// </summary>
/// <value>The name.</value>
[ApiMember(Name = "PackageType", Description = "Optional package type filter (System/UserInstalled)", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public PackageType? PackageType { get; set; }
public string PackageType { get; set; }

[ApiMember(Name = "TargetSystems", Description = "Optional. Filter by target system type. Allows multiple, comma delimited.", IsRequired = false, DataType = "string", ParameterType = "path", Verb = "GET", AllowMultiple = true)]
public string TargetSystems { get; set; }
Expand All @@ -72,7 +72,7 @@ public class GetPackageVersionUpdates : IReturn<List<PackageVersionInfo>>
/// </summary>
/// <value>The name.</value>
[ApiMember(Name = "PackageType", Description = "Package type filter (System/UserInstalled)", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
public PackageType PackageType { get; set; }
public string PackageType { get; set; }
}

/// <summary>
Expand Down Expand Up @@ -149,12 +149,12 @@ public object Get(GetPackageVersionUpdates request)
{
var result = new List<PackageVersionInfo>();

if (request.PackageType == PackageType.UserInstalled || request.PackageType == PackageType.All)
if (string.Equals(request.PackageType, "UserInstalled", StringComparison.OrdinalIgnoreCase) || string.Equals(request.PackageType, "All", StringComparison.OrdinalIgnoreCase))
{
result.AddRange(_installationManager.GetAvailablePluginUpdates(_appHost.ApplicationVersion, false, CancellationToken.None).Result.ToList());
}

else if (request.PackageType == PackageType.System || request.PackageType == PackageType.All)
else if (string.Equals(request.PackageType, "System", StringComparison.OrdinalIgnoreCase) || string.Equals(request.PackageType, "All", StringComparison.OrdinalIgnoreCase))
{
var updateCheckResult = _appHost.CheckForApplicationUpdate(CancellationToken.None, new Progress<double>()).Result;

Expand Down
3 changes: 0 additions & 3 deletions MediaBrowser.Api/Playback/BaseStreamingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1857,9 +1857,6 @@ protected async Task<StreamState> GetState(StreamRequest request, CancellationTo

state.IsInputVideo = string.Equals(item.MediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase);

var archivable = item as IArchivable;
state.IsInputArchive = archivable != null && archivable.IsArchive;

MediaSourceInfo mediaSource = null;
if (string.IsNullOrWhiteSpace(request.LiveStreamId))
{
Expand Down
1 change: 0 additions & 1 deletion MediaBrowser.Api/Playback/StreamState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public bool IsOutputVideo
get { return Request is VideoStreamRequest; }
}
public bool IsInputVideo { get; set; }
public bool IsInputArchive { get; set; }

public VideoType VideoType { get; set; }
public IsoType? IsoType { get; set; }
Expand Down
4 changes: 0 additions & 4 deletions MediaBrowser.Api/Reports/Data/ReportBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -517,10 +517,6 @@ private ReportOptions<BaseItem> GetOption(HeaderMetadata header, string sortFiel
internalHeader = HeaderMetadata.Album;
break;

case HeaderMetadata.Countries:
option.Column = (i, r) => this.GetListAsString(this.GetObject<IHasProductionLocations, List<string>>(i, (x) => x.ProductionLocations));
break;

case HeaderMetadata.Disc:
option.Column = (i, r) => i.ParentIndexNumber;
break;
Expand Down
25 changes: 0 additions & 25 deletions MediaBrowser.Api/Reports/Stat/ReportStatBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public ReportStatResult GetResult(BaseItem[] items, ReportIncludeItemTypes repor
result = this.GetResultStudios(result, items, topItem);
result = this.GetResultPersons(result, items, topItem);
result = this.GetResultProductionYears(result, items, topItem);
result = this.GetResulProductionLocations(result, items, topItem);
result = this.GetResultCommunityRatings(result, items, topItem);
result = this.GetResultParentalRatings(result, items, topItem);

Expand Down Expand Up @@ -100,30 +99,6 @@ private void GetGroups(ReportStatResult result, string header, int topItem, IEnu
}
}

/// <summary> Gets resul production locations. </summary>
/// <param name="result"> The result. </param>
/// <param name="items"> The items. </param>
/// <param name="topItem"> The top item. </param>
/// <returns> The resul production locations. </returns>
private ReportStatResult GetResulProductionLocations(ReportStatResult result, BaseItem[] items, int topItem = 5)
{
this.GetGroups(result, GetLocalizedHeader(HeaderMetadata.Countries), topItem,
items.OfType<IHasProductionLocations>()
.Where(x => x.ProductionLocations != null)
.SelectMany(x => x.ProductionLocations)
.GroupBy(x => x)
.OrderByDescending(x => x.Count())
.Take(topItem)
.Select(x => new ReportStatItem
{
Name = x.Key.ToString(),
Value = x.Count().ToString()
})
);

return result;
}

/// <summary> Gets result community ratings. </summary>
/// <param name="result"> The result. </param>
/// <param name="items"> The items. </param>
Expand Down
3 changes: 2 additions & 1 deletion MediaBrowser.Api/SimilarItemsHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ internal static async Task<QueryResult<BaseItemDto>> GetSimilarItemsResult(DtoOp
var query = new InternalItemsQuery(user)
{
IncludeItemTypes = includeTypes.Select(i => i.Name).ToArray(),
Recursive = true
Recursive = true,
Fields = dtoOptions.Fields
};

// ExcludeArtistIds
Expand Down
2 changes: 2 additions & 0 deletions MediaBrowser.Api/StartupWizardService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ private void SetWizardFinishValues(ServerConfiguration config)
config.EnableFolderView = true;
config.SchemaVersion = 109;
config.EnableSimpleArtistDetection = true;
config.SkipDeserializationForBasicTypes = true;
config.SkipDeserializationForPrograms = true;
}

public void Post(UpdateStartupConfiguration request)
Expand Down
14 changes: 8 additions & 6 deletions MediaBrowser.Api/TvShowsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,19 +302,20 @@ private async Task<QueryResult<BaseItemDto>> GetSimilarItemsResult(BaseGetSimila
(!string.IsNullOrWhiteSpace(request.UserId) ? user.RootFolder :
_libraryManager.RootFolder) : _libraryManager.GetItemById(request.Id);

var dtoOptions = GetDtoOptions(request);

var itemsResult = _libraryManager.GetItemList(new InternalItemsQuery(user)
{
Limit = request.Limit,
IncludeItemTypes = new[]
{
typeof(Series).Name
},
SimilarTo = item
SimilarTo = item,
Fields = dtoOptions.Fields

}).ToList();

var dtoOptions = GetDtoOptions(request);

var result = new QueryResult<BaseItemDto>
{
Items = (await _dtoService.GetBaseItemDtos(itemsResult, dtoOptions, user).ConfigureAwait(false)).ToArray(),
Expand All @@ -333,6 +334,8 @@ public async Task<object> Get(GetUpcomingEpisodes request)

var parentIdGuid = string.IsNullOrWhiteSpace(request.ParentId) ? (Guid?)null : new Guid(request.ParentId);

var options = GetDtoOptions(request);

var itemsResult = _libraryManager.GetItemList(new InternalItemsQuery(user)
{
IncludeItemTypes = new[] { typeof(Episode).Name },
Expand All @@ -342,12 +345,11 @@ public async Task<object> Get(GetUpcomingEpisodes request)
StartIndex = request.StartIndex,
Limit = request.Limit,
ParentId = parentIdGuid,
Recursive = true
Recursive = true,
Fields = options.Fields

}).ToList();

var options = GetDtoOptions(request);

var returnItems = (await _dtoService.GetBaseItemDtos(itemsResult, options, user).ConfigureAwait(false)).ToArray();

var result = new ItemsResult
Expand Down
Loading

0 comments on commit 5cd3276

Please sign in to comment.