add episode number to reports
This commit is contained in:
parent
92eeee0fc5
commit
fa132ada88
|
@ -82,10 +82,6 @@
|
||||||
<Compile Include="Reports\Model\ReportRow.cs" />
|
<Compile Include="Reports\Model\ReportRow.cs" />
|
||||||
<Compile Include="Reports\ReportRequests.cs" />
|
<Compile Include="Reports\ReportRequests.cs" />
|
||||||
<Compile Include="Reports\ReportsService.cs" />
|
<Compile Include="Reports\ReportsService.cs" />
|
||||||
<Compile Include="Reports\Stat\ReportStatBuilder.cs" />
|
|
||||||
<Compile Include="Reports\Stat\ReportStatGroup.cs" />
|
|
||||||
<Compile Include="Reports\Stat\ReportStatItem.cs" />
|
|
||||||
<Compile Include="Reports\Stat\ReportStatResult.cs" />
|
|
||||||
<Compile Include="Social\SharingService.cs" />
|
<Compile Include="Social\SharingService.cs" />
|
||||||
<Compile Include="StartupWizardService.cs" />
|
<Compile Include="StartupWizardService.cs" />
|
||||||
<Compile Include="Subtitles\SubtitleService.cs" />
|
<Compile Include="Subtitles\SubtitleService.cs" />
|
||||||
|
|
|
@ -35,6 +35,7 @@ namespace MediaBrowser.Api.Reports
|
||||||
Tracks,
|
Tracks,
|
||||||
EpisodeSeries,
|
EpisodeSeries,
|
||||||
EpisodeSeason,
|
EpisodeSeason,
|
||||||
|
EpisodeNumber,
|
||||||
AudioAlbumArtist,
|
AudioAlbumArtist,
|
||||||
MusicArtist,
|
MusicArtist,
|
||||||
AudioAlbum,
|
AudioAlbum,
|
||||||
|
|
|
@ -148,6 +148,11 @@ namespace MediaBrowser.Api.Reports
|
||||||
/// <returns> The localized header. </returns>
|
/// <returns> The localized header. </returns>
|
||||||
protected static string GetLocalizedHeader(HeaderMetadata internalHeader)
|
protected static string GetLocalizedHeader(HeaderMetadata internalHeader)
|
||||||
{
|
{
|
||||||
|
if (internalHeader == HeaderMetadata.EpisodeNumber)
|
||||||
|
{
|
||||||
|
return "Episode";
|
||||||
|
}
|
||||||
|
|
||||||
string headerName = "";
|
string headerName = "";
|
||||||
if (internalHeader != HeaderMetadata.None)
|
if (internalHeader != HeaderMetadata.None)
|
||||||
{
|
{
|
||||||
|
|
|
@ -272,6 +272,7 @@ namespace MediaBrowser.Api.Reports
|
||||||
HeaderMetadata.Name,
|
HeaderMetadata.Name,
|
||||||
HeaderMetadata.EpisodeSeries,
|
HeaderMetadata.EpisodeSeries,
|
||||||
HeaderMetadata.Season,
|
HeaderMetadata.Season,
|
||||||
|
HeaderMetadata.EpisodeNumber,
|
||||||
HeaderMetadata.DateAdded,
|
HeaderMetadata.DateAdded,
|
||||||
HeaderMetadata.ReleaseDate,
|
HeaderMetadata.ReleaseDate,
|
||||||
HeaderMetadata.Year,
|
HeaderMetadata.Year,
|
||||||
|
@ -450,6 +451,12 @@ namespace MediaBrowser.Api.Reports
|
||||||
internalHeader = HeaderMetadata.Season;
|
internalHeader = HeaderMetadata.Season;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case HeaderMetadata.EpisodeNumber:
|
||||||
|
option.Column = (i, r) => this.GetObject<BaseItem, string>(i, (x) => x.IndexNumber == null ? "" : x.IndexNumber.ToString());
|
||||||
|
//option.Header.SortField = "IndexNumber";
|
||||||
|
//option.Header.HeaderFieldType = ReportFieldType.Int;
|
||||||
|
break;
|
||||||
|
|
||||||
case HeaderMetadata.Network:
|
case HeaderMetadata.Network:
|
||||||
option.Column = (i, r) => this.GetListAsString(i.Studios);
|
option.Column = (i, r) => this.GetListAsString(i.Studios);
|
||||||
option.ItemID = (i) => this.GetStudioID(i.Studios.FirstOrDefault());
|
option.ItemID = (i) => this.GetStudioID(i.Studios.FirstOrDefault());
|
||||||
|
|
|
@ -1,256 +0,0 @@
|
||||||
using MediaBrowser.Controller.Entities;
|
|
||||||
using MediaBrowser.Controller.Library;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Api.Reports
|
|
||||||
{
|
|
||||||
/// <summary> A report stat builder. </summary>
|
|
||||||
/// <seealso cref="T:MediaBrowser.Api.Reports.ReportBuilderBase"/>
|
|
||||||
public class ReportStatBuilder : ReportBuilderBase
|
|
||||||
{
|
|
||||||
#region [Constructors]
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the MediaBrowser.Api.Reports.ReportStatBuilder class. </summary>
|
|
||||||
/// <param name="libraryManager"> Manager for library. </param>
|
|
||||||
public ReportStatBuilder(ILibraryManager libraryManager)
|
|
||||||
: base(libraryManager)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region [Public Methods]
|
|
||||||
|
|
||||||
/// <summary> Gets report stat result. </summary>
|
|
||||||
/// <param name="items"> The items. </param>
|
|
||||||
/// <param name="reportIncludeItemTypes"> List of types of the report include items. </param>
|
|
||||||
/// <param name="topItem"> The top item. </param>
|
|
||||||
/// <returns> The report stat result. </returns>
|
|
||||||
public ReportStatResult GetResult(BaseItem[] items, ReportIncludeItemTypes reportIncludeItemTypes, int topItem = 5)
|
|
||||||
{
|
|
||||||
ReportStatResult result = new ReportStatResult();
|
|
||||||
result = this.GetResultGenres(result, items, topItem);
|
|
||||||
result = this.GetResultStudios(result, items, topItem);
|
|
||||||
result = this.GetResultPersons(result, items, topItem);
|
|
||||||
result = this.GetResultProductionYears(result, items, topItem);
|
|
||||||
result = this.GetResultCommunityRatings(result, items, topItem);
|
|
||||||
result = this.GetResultParentalRatings(result, items, topItem);
|
|
||||||
|
|
||||||
switch (reportIncludeItemTypes)
|
|
||||||
{
|
|
||||||
case ReportIncludeItemTypes.Season:
|
|
||||||
case ReportIncludeItemTypes.Series:
|
|
||||||
case ReportIncludeItemTypes.MusicAlbum:
|
|
||||||
case ReportIncludeItemTypes.MusicArtist:
|
|
||||||
case ReportIncludeItemTypes.Game:
|
|
||||||
break;
|
|
||||||
case ReportIncludeItemTypes.Movie:
|
|
||||||
case ReportIncludeItemTypes.BoxSet:
|
|
||||||
|
|
||||||
break;
|
|
||||||
case ReportIncludeItemTypes.Book:
|
|
||||||
case ReportIncludeItemTypes.Episode:
|
|
||||||
case ReportIncludeItemTypes.Video:
|
|
||||||
case ReportIncludeItemTypes.MusicVideo:
|
|
||||||
case ReportIncludeItemTypes.Trailer:
|
|
||||||
case ReportIncludeItemTypes.Audio:
|
|
||||||
case ReportIncludeItemTypes.BaseItem:
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
result.Groups = result.Groups.OrderByDescending(n => n.Items.Count()).ToList();
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region [Protected Internal Methods]
|
|
||||||
/// <summary> Gets the headers. </summary>
|
|
||||||
/// <typeparam name="H"> Type of the header. </typeparam>
|
|
||||||
/// <param name="request"> The request. </param>
|
|
||||||
/// <returns> The headers. </returns>
|
|
||||||
/// <seealso cref="M:MediaBrowser.Api.Reports.ReportBuilderBase.GetHeaders{H}(H)"/>
|
|
||||||
protected internal override List<ReportHeader> GetHeaders<H>(H request)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region [Private Methods]
|
|
||||||
|
|
||||||
/// <summary> Gets the groups. </summary>
|
|
||||||
/// <param name="result"> The result. </param>
|
|
||||||
/// <param name="header"> The header. </param>
|
|
||||||
/// <param name="topItem"> The top item. </param>
|
|
||||||
/// <param name="top"> The top. </param>
|
|
||||||
private void GetGroups(ReportStatResult result, string header, int topItem, IEnumerable<ReportStatItem> top)
|
|
||||||
{
|
|
||||||
if (top != null && top.Count() > 0)
|
|
||||||
{
|
|
||||||
var group = new ReportStatGroup { Header = ReportStatGroup.FormatedHeader(header, topItem) };
|
|
||||||
group.Items.AddRange(top);
|
|
||||||
result.Groups.Add(group);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> Gets result community ratings. </summary>
|
|
||||||
/// <param name="result"> The result. </param>
|
|
||||||
/// <param name="items"> The items. </param>
|
|
||||||
/// <param name="topItem"> The top item. </param>
|
|
||||||
/// <returns> The result community ratings. </returns>
|
|
||||||
private ReportStatResult GetResultCommunityRatings(ReportStatResult result, BaseItem[] items, int topItem = 5)
|
|
||||||
{
|
|
||||||
this.GetGroups(result, GetLocalizedHeader(HeaderMetadata.CommunityRating), topItem,
|
|
||||||
items.Where(x => x.CommunityRating != null && x.CommunityRating > 0)
|
|
||||||
.GroupBy(x => x.CommunityRating)
|
|
||||||
.OrderByDescending(x => x.Count())
|
|
||||||
.Take(topItem)
|
|
||||||
.Select(x => new ReportStatItem
|
|
||||||
{
|
|
||||||
Name = x.Key.ToString(),
|
|
||||||
Value = x.Count().ToString()
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> Gets result genres. </summary>
|
|
||||||
/// <param name="result"> The result. </param>
|
|
||||||
/// <param name="items"> The items. </param>
|
|
||||||
/// <param name="topItem"> The top item. </param>
|
|
||||||
/// <returns> The result genres. </returns>
|
|
||||||
private ReportStatResult GetResultGenres(ReportStatResult result, BaseItem[] items, int topItem = 5)
|
|
||||||
{
|
|
||||||
this.GetGroups(result, GetLocalizedHeader(HeaderMetadata.Genres), topItem,
|
|
||||||
items.SelectMany(x => x.Genres)
|
|
||||||
.GroupBy(x => x)
|
|
||||||
.OrderByDescending(x => x.Count())
|
|
||||||
.Take(topItem)
|
|
||||||
.Select(x => new ReportStatItem
|
|
||||||
{
|
|
||||||
Name = x.Key,
|
|
||||||
Value = x.Count().ToString(),
|
|
||||||
Id = GetGenreID(x.Key)
|
|
||||||
}));
|
|
||||||
return result;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> Gets result parental ratings. </summary>
|
|
||||||
/// <param name="result"> The result. </param>
|
|
||||||
/// <param name="items"> The items. </param>
|
|
||||||
/// <param name="topItem"> The top item. </param>
|
|
||||||
/// <returns> The result parental ratings. </returns>
|
|
||||||
private ReportStatResult GetResultParentalRatings(ReportStatResult result, BaseItem[] items, int topItem = 5)
|
|
||||||
{
|
|
||||||
this.GetGroups(result, GetLocalizedHeader(HeaderMetadata.ParentalRatings), topItem,
|
|
||||||
items.Where(x => x.OfficialRating != null)
|
|
||||||
.GroupBy(x => x.OfficialRating)
|
|
||||||
.OrderByDescending(x => x.Count())
|
|
||||||
.Take(topItem)
|
|
||||||
.Select(x => new ReportStatItem
|
|
||||||
{
|
|
||||||
Name = x.Key.ToString(),
|
|
||||||
Value = x.Count().ToString()
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> Gets result persons. </summary>
|
|
||||||
/// <param name="result"> The result. </param>
|
|
||||||
/// <param name="items"> The items. </param>
|
|
||||||
/// <param name="topItem"> The top item. </param>
|
|
||||||
/// <returns> The result persons. </returns>
|
|
||||||
private ReportStatResult GetResultPersons(ReportStatResult result, BaseItem[] items, int topItem = 5)
|
|
||||||
{
|
|
||||||
List<HeaderMetadata> t = new List<HeaderMetadata>
|
|
||||||
{
|
|
||||||
HeaderMetadata.Actor,
|
|
||||||
HeaderMetadata.Composer,
|
|
||||||
HeaderMetadata.Director,
|
|
||||||
HeaderMetadata.GuestStar,
|
|
||||||
HeaderMetadata.Producer,
|
|
||||||
HeaderMetadata.Writer,
|
|
||||||
HeaderMetadata.Artist,
|
|
||||||
HeaderMetadata.AlbumArtist
|
|
||||||
};
|
|
||||||
foreach (var item in t)
|
|
||||||
{
|
|
||||||
var ps = items.SelectMany(x => _libraryManager.GetPeople(x))
|
|
||||||
.Where(n => n.Type == item.ToString())
|
|
||||||
.GroupBy(x => x.Name)
|
|
||||||
.OrderByDescending(x => x.Count())
|
|
||||||
.Take(topItem);
|
|
||||||
if (ps != null && ps.Count() > 0)
|
|
||||||
this.GetGroups(result, GetLocalizedHeader(item), topItem,
|
|
||||||
ps.Select(x => new ReportStatItem
|
|
||||||
{
|
|
||||||
Name = x.Key,
|
|
||||||
Value = x.Count().ToString(),
|
|
||||||
Id = GetPersonID(x.Key)
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> Gets result production years. </summary>
|
|
||||||
/// <param name="result"> The result. </param>
|
|
||||||
/// <param name="items"> The items. </param>
|
|
||||||
/// <param name="topItem"> The top item. </param>
|
|
||||||
/// <returns> The result production years. </returns>
|
|
||||||
private ReportStatResult GetResultProductionYears(ReportStatResult result, BaseItem[] items, int topItem = 5)
|
|
||||||
{
|
|
||||||
this.GetGroups(result, GetLocalizedHeader(HeaderMetadata.Year), topItem,
|
|
||||||
items.Where(x => x.ProductionYear != null && x.ProductionYear > 0)
|
|
||||||
.GroupBy(x => x.ProductionYear)
|
|
||||||
.OrderByDescending(x => x.Count())
|
|
||||||
.Take(topItem)
|
|
||||||
.Select(x => new ReportStatItem
|
|
||||||
{
|
|
||||||
Name = x.Key.ToString(),
|
|
||||||
Value = x.Count().ToString()
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> Gets result studios. </summary>
|
|
||||||
/// <param name="result"> The result. </param>
|
|
||||||
/// <param name="items"> The items. </param>
|
|
||||||
/// <param name="topItem"> The top item. </param>
|
|
||||||
/// <returns> The result studios. </returns>
|
|
||||||
private ReportStatResult GetResultStudios(ReportStatResult result, BaseItem[] items, int topItem = 5)
|
|
||||||
{
|
|
||||||
this.GetGroups(result, GetLocalizedHeader(HeaderMetadata.Studios), topItem,
|
|
||||||
items.SelectMany(x => x.Studios)
|
|
||||||
.GroupBy(x => x)
|
|
||||||
.OrderByDescending(x => x.Count())
|
|
||||||
.Take(topItem)
|
|
||||||
.Select(x => new ReportStatItem
|
|
||||||
{
|
|
||||||
Name = x.Key,
|
|
||||||
Value = x.Count().ToString(),
|
|
||||||
Id = GetStudioID(x.Key)
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Api.Reports
|
|
||||||
{
|
|
||||||
/// <summary> A report stat group. </summary>
|
|
||||||
public class ReportStatGroup
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the MediaBrowser.Api.Reports.ReportStatGroup class. </summary>
|
|
||||||
public ReportStatGroup()
|
|
||||||
{
|
|
||||||
Items = new List<ReportStatItem>();
|
|
||||||
TotalRecordCount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> Gets or sets the header. </summary>
|
|
||||||
/// <value> The header. </value>
|
|
||||||
public string Header { get; set; }
|
|
||||||
|
|
||||||
/// <summary> Gets or sets the items. </summary>
|
|
||||||
/// <value> The items. </value>
|
|
||||||
public List<ReportStatItem> Items { get; set; }
|
|
||||||
|
|
||||||
/// <summary> Gets or sets the number of total records. </summary>
|
|
||||||
/// <value> The total number of record count. </value>
|
|
||||||
public int TotalRecordCount { get; set; }
|
|
||||||
|
|
||||||
internal static string FormatedHeader(string header, int topItem)
|
|
||||||
{
|
|
||||||
return string.Format("Top {0} {1}", topItem, header);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
namespace MediaBrowser.Api.Reports
|
|
||||||
{
|
|
||||||
/// <summary> A report stat item. </summary>
|
|
||||||
public class ReportStatItem
|
|
||||||
{
|
|
||||||
/// <summary> Gets or sets the name. </summary>
|
|
||||||
/// <value> The name. </value>
|
|
||||||
public string Name { get; set; }
|
|
||||||
|
|
||||||
/// <summary> Gets or sets the image. </summary>
|
|
||||||
/// <value> The image. </value>
|
|
||||||
public string Image { get; set; }
|
|
||||||
|
|
||||||
/// <summary> Gets or sets the value. </summary>
|
|
||||||
/// <value> The value. </value>
|
|
||||||
public string Value { get; set; }
|
|
||||||
|
|
||||||
/// <summary> Gets or sets the identifier. </summary>
|
|
||||||
/// <value> The identifier. </value>
|
|
||||||
public string Id { get; set; }
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Api.Reports
|
|
||||||
{
|
|
||||||
/// <summary> Encapsulates the result of a report stat. </summary>
|
|
||||||
public class ReportStatResult
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the MediaBrowser.Api.Reports.ReportStatResult class. </summary>
|
|
||||||
public ReportStatResult()
|
|
||||||
{
|
|
||||||
Groups = new List<ReportStatGroup>();
|
|
||||||
TotalRecordCount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> Gets or sets the groups. </summary>
|
|
||||||
/// <value> The groups. </value>
|
|
||||||
public List<ReportStatGroup> Groups { get; set; }
|
|
||||||
|
|
||||||
/// <summary> Gets or sets the number of total records. </summary>
|
|
||||||
/// <value> The total number of record count. </value>
|
|
||||||
public int TotalRecordCount { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user