The Free Software Media System - Server Backend & API
stub out reports api
Luke Pulverenti49def5de6a10
diff --git a/MediaBrowser.Api/MediaBrowser.Api.csproj b/MediaBrowser.Api/MediaBrowser.Api.csprojindex 23cdf8b7a7..2713059212 100644--- a/MediaBrowser.Api/MediaBrowser.Api.csproj+++ b/MediaBrowser.Api/MediaBrowser.Api.csproj@@ -82,6 +82,10 @@<Compile Include="Playback\Hls\MpegDashService.cs" /><Compile Include="Playback\MediaInfoService.cs" /><Compile Include="PlaylistService.cs" />+ <Compile Include="Reports\ReportFieldType.cs" />+ <Compile Include="Reports\ReportResult.cs" />+ <Compile Include="Reports\ReportsService.cs" />+ <Compile Include="Reports\ReportRequests.cs" /><Compile Include="StartupWizardService.cs" /><Compile Include="Subtitles\SubtitleService.cs" /><Compile Include="Movies\CollectionService.cs" />diff --git a/MediaBrowser.Api/Reports/ReportFieldType.cs b/MediaBrowser.Api/Reports/ReportFieldType.csnew file mode 100644index 0000000000..d35c5cb2da--- /dev/null+++ b/MediaBrowser.Api/Reports/ReportFieldType.cs@@ -0,0 +1,9 @@++namespace MediaBrowser.Api.Reports+{+ public enum ReportFieldType+ {+ String,+ Boolean+ }+}diff --git a/MediaBrowser.Api/Reports/ReportRequests.cs b/MediaBrowser.Api/Reports/ReportRequests.csnew file mode 100644index 0000000000..8dea003814--- /dev/null+++ b/MediaBrowser.Api/Reports/ReportRequests.cs@@ -0,0 +1,33 @@+using ServiceStack;++namespace MediaBrowser.Api.Reports+{+ public class BaseReportRequest : IReturn<ReportResult>+ {+ /// <summary>+ /// Specify this to localize the search to a specific item or folder. Omit to use the root.+ /// </summary>+ /// <value>The parent id.</value>+ [ApiMember(Name = "ParentId", Description = "Specify this to localize the search to a specific item or folder. Omit to use the root", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]+ public string ParentId { get; set; }++ /// <summary>+ /// Skips over a given number of items within the results. Use for paging.+ /// </summary>+ /// <value>The start index.</value>+ [ApiMember(Name = "StartIndex", Description = "Optional. The record index to start at. All items with a lower index will be dropped from the results.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]+ public int? StartIndex { get; set; }++ /// <summary>+ /// The maximum number of items to return+ /// </summary>+ /// <value>The limit.</value>+ [ApiMember(Name = "Limit", Description = "Optional. The maximum number of records to return", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]+ public int? Limit { get; set; }+ }++ [Route("/Reports/Items", "GET", Summary = "Gets reports based on library items")]+ public class GetItemReport : BaseReportRequest+ {+ }+}diff --git a/MediaBrowser.Api/Reports/ReportResult.cs b/MediaBrowser.Api/Reports/ReportResult.csnew file mode 100644index 0000000000..c033ae8fb7--- /dev/null+++ b/MediaBrowser.Api/Reports/ReportResult.cs@@ -0,0 +1,16 @@+using System.Collections.Generic;++namespace MediaBrowser.Api.Reports+{+ public class ReportResult+ {+ public List<List<string>> Rows { get; set; }+ public List<ReportFieldType> Columns { get; set; }++ public ReportResult()+ {+ Rows = new List<List<string>>();+ Columns = new List<ReportFieldType>();+ }+ }+}diff --git a/MediaBrowser.Api/Reports/ReportsService.cs b/MediaBrowser.Api/Reports/ReportsService.csnew file mode 100644index 0000000000..45bc4a8893--- /dev/null+++ b/MediaBrowser.Api/Reports/ReportsService.cs@@ -0,0 +1,64 @@+using MediaBrowser.Controller.Entities;+using MediaBrowser.Controller.Library;+using MediaBrowser.Model.Querying;+using System.Threading.Tasks;++namespace MediaBrowser.Api.Reports+{+ public class ReportsService : BaseApiService+ {+ private readonly ILibraryManager _libraryManager;++ public ReportsService(ILibraryManager libraryManager)+ {+ _libraryManager = libraryManager;+ }++ public async Task<object> Get(GetItemReport request)+ {+ var queryResult = await GetQueryResult(request).ConfigureAwait(false);++ var reportResult = GetReportResult(queryResult);++ return ToOptimizedResult(reportResult);+ }++ private ReportResult GetReportResult(QueryResult<BaseItem> queryResult)+ {+ var reportResult = new ReportResult();++ // Fill rows and columns++ return reportResult;+ }++ private Task<QueryResult<BaseItem>> GetQueryResult(BaseReportRequest request)+ {+ // Placeholder in case needed later+ User user = null;++ var parentItem = string.IsNullOrEmpty(request.ParentId) ?+ (user == null ? _libraryManager.RootFolder : user.RootFolder) :+ _libraryManager.GetItemById(request.ParentId);++ return ((Folder)parentItem).GetItems(GetItemsQuery(request, user));+ }++ private InternalItemsQuery GetItemsQuery(BaseReportRequest request, User user)+ {+ var query = new InternalItemsQuery+ {+ User = user,+ CollapseBoxSetItems = false+ };++ // Set query values based on request++ // Example+ //query.IncludeItemTypes = new[] {"Movie"};+++ return query;+ }+ }+}