Reports - icons and people fix
This commit is contained in:
parent
27d6135493
commit
0fa55fd6de
|
@ -159,7 +159,17 @@ namespace MediaBrowser.Api.Reports
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HeaderMetadata.UserPrimaryImageTag:
|
case HeaderMetadata.UserPrimaryImageTag:
|
||||||
option.Column = (i, r) => i.UserPrimaryImageTag;
|
//option.Column = (i, r) => i.UserPrimaryImageTag;
|
||||||
|
option.Column = (i, r) =>
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(i.UserId))
|
||||||
|
{
|
||||||
|
MediaBrowser.Controller.Entities.User user = _userManager.GetUserById(i.UserId);
|
||||||
|
if (user != null)
|
||||||
|
return user.PrimaryImagePath;
|
||||||
|
}
|
||||||
|
return string.Empty;
|
||||||
|
};
|
||||||
option.Header.SortField = "";
|
option.Header.SortField = "";
|
||||||
break;
|
break;
|
||||||
case HeaderMetadata.Severity:
|
case HeaderMetadata.Severity:
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -9,206 +9,266 @@ using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace MediaBrowser.Api.Reports
|
namespace MediaBrowser.Api.Reports
|
||||||
{
|
{
|
||||||
/// <summary> A report stat builder. </summary>
|
/// <summary> A report stat builder. </summary>
|
||||||
/// <seealso cref="T:MediaBrowser.Api.Reports.ReportBuilderBase"/>
|
/// <seealso cref="T:MediaBrowser.Api.Reports.ReportBuilderBase"/>
|
||||||
public class ReportStatBuilder : ReportBuilderBase
|
public class ReportStatBuilder : ReportBuilderBase
|
||||||
{
|
{
|
||||||
/// <summary>
|
#region [Constructors]
|
||||||
/// 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)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> Gets report stat result. </summary>
|
/// <summary>
|
||||||
/// <param name="items"> The items. </param>
|
/// Initializes a new instance of the MediaBrowser.Api.Reports.ReportStatBuilder class. </summary>
|
||||||
/// <param name="reportRowType"> Type of the report row. </param>
|
/// <param name="libraryManager"> Manager for library. </param>
|
||||||
/// <param name="topItem"> The top item. </param>
|
public ReportStatBuilder(ILibraryManager libraryManager)
|
||||||
/// <returns> The report stat result. </returns>
|
: base(libraryManager)
|
||||||
public ReportStatResult GetReportStatResult(BaseItem[] items, ReportViewType reportRowType, 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.GetResulProductionLocations(result, items, topItem);
|
|
||||||
result = this.GetResultCommunityRatings(result, items, topItem);
|
|
||||||
result = this.GetResultParentalRatings(result, items, topItem);
|
|
||||||
|
|
||||||
switch (reportRowType)
|
#endregion
|
||||||
{
|
|
||||||
case ReportViewType.Season:
|
|
||||||
case ReportViewType.Series:
|
|
||||||
case ReportViewType.MusicAlbum:
|
|
||||||
case ReportViewType.MusicArtist:
|
|
||||||
case ReportViewType.Game:
|
|
||||||
break;
|
|
||||||
case ReportViewType.Movie:
|
|
||||||
case ReportViewType.BoxSet:
|
|
||||||
|
|
||||||
break;
|
#region [Public Methods]
|
||||||
case ReportViewType.Book:
|
|
||||||
case ReportViewType.Episode:
|
|
||||||
case ReportViewType.Video:
|
|
||||||
case ReportViewType.MusicVideo:
|
|
||||||
case ReportViewType.Trailer:
|
|
||||||
case ReportViewType.Audio:
|
|
||||||
case ReportViewType.BaseItem:
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
result.Groups = result.Groups.OrderByDescending(n => n.Items.Count()).ToList();
|
/// <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.GetResulProductionLocations(result, items, topItem);
|
||||||
|
result = this.GetResultCommunityRatings(result, items, topItem);
|
||||||
|
result = this.GetResultParentalRatings(result, items, topItem);
|
||||||
|
|
||||||
return result;
|
switch (reportIncludeItemTypes)
|
||||||
}
|
{
|
||||||
|
case ReportIncludeItemTypes.Season:
|
||||||
|
case ReportIncludeItemTypes.Series:
|
||||||
|
case ReportIncludeItemTypes.MusicAlbum:
|
||||||
|
case ReportIncludeItemTypes.MusicArtist:
|
||||||
|
case ReportIncludeItemTypes.Game:
|
||||||
|
break;
|
||||||
|
case ReportIncludeItemTypes.Movie:
|
||||||
|
case ReportIncludeItemTypes.BoxSet:
|
||||||
|
|
||||||
private ReportStatResult GetResultGenres(ReportStatResult result, BaseItem[] items, int topItem = 5)
|
break;
|
||||||
{
|
case ReportIncludeItemTypes.Book:
|
||||||
this.GetGroups(result, ReportHelper.GetServerLocalizedString("HeaderGenres"), topItem,
|
case ReportIncludeItemTypes.Episode:
|
||||||
items.SelectMany(x => x.Genres)
|
case ReportIncludeItemTypes.Video:
|
||||||
.GroupBy(x => x)
|
case ReportIncludeItemTypes.MusicVideo:
|
||||||
.OrderByDescending(x => x.Count())
|
case ReportIncludeItemTypes.Trailer:
|
||||||
.Take(topItem)
|
case ReportIncludeItemTypes.Audio:
|
||||||
.Select(x => new ReportStatItem
|
case ReportIncludeItemTypes.BaseItem:
|
||||||
{
|
default:
|
||||||
Name = x.Key,
|
break;
|
||||||
Value = x.Count().ToString(),
|
}
|
||||||
Id = GetGenreID(x.Key)
|
|
||||||
}));
|
|
||||||
return result;
|
|
||||||
|
|
||||||
}
|
result.Groups = result.Groups.OrderByDescending(n => n.Items.Count()).ToList();
|
||||||
|
|
||||||
private ReportStatResult GetResultStudios(ReportStatResult result, BaseItem[] items, int topItem = 5)
|
return result;
|
||||||
{
|
}
|
||||||
this.GetGroups(result, ReportHelper.GetServerLocalizedString("HeaderStudios"), 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
|
||||||
|
|
||||||
}
|
#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();
|
||||||
|
}
|
||||||
|
|
||||||
private ReportStatResult GetResultPersons(ReportStatResult result, BaseItem[] items, int topItem = 5)
|
#endregion
|
||||||
{
|
|
||||||
List<string> t = new List<string> { PersonType.Actor, PersonType.Composer, PersonType.Director, PersonType.GuestStar, PersonType.Producer, PersonType.Writer, "Artist", "AlbumArtist" };
|
|
||||||
foreach (var item in t)
|
|
||||||
{
|
|
||||||
this.GetGroups(result, ReportHelper.GetServerLocalizedString("Option" + item), topItem,
|
|
||||||
items.SelectMany(x => _libraryManager.GetPeople(x))
|
|
||||||
.Where(n => n.Type == item)
|
|
||||||
.GroupBy(x => x.Name)
|
|
||||||
.OrderByDescending(x => x.Count())
|
|
||||||
.Take(topItem)
|
|
||||||
.Select(x => new ReportStatItem
|
|
||||||
{
|
|
||||||
Name = x.Key,
|
|
||||||
Value = x.Count().ToString(),
|
|
||||||
Id = GetPersonID(x.Key)
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
#region [Private Methods]
|
||||||
}
|
|
||||||
|
|
||||||
private ReportStatResult GetResultCommunityRatings(ReportStatResult result, BaseItem[] items, int topItem = 5)
|
/// <summary> Gets the groups. </summary>
|
||||||
{
|
/// <param name="result"> The result. </param>
|
||||||
this.GetGroups(result, ReportHelper.GetServerLocalizedString("LabelCommunityRating"), topItem,
|
/// <param name="header"> The header. </param>
|
||||||
items.Where(x => x.CommunityRating != null && x.CommunityRating > 0)
|
/// <param name="topItem"> The top item. </param>
|
||||||
.GroupBy(x => x.CommunityRating)
|
/// <param name="top"> The top. </param>
|
||||||
.OrderByDescending(x => x.Count())
|
private void GetGroups(ReportStatResult result, string header, int topItem, IEnumerable<ReportStatItem> top)
|
||||||
.Take(topItem)
|
{
|
||||||
.Select(x => new ReportStatItem
|
if (top != null && top.Count() > 0)
|
||||||
{
|
{
|
||||||
Name = x.Key.ToString(),
|
var group = new ReportStatGroup { Header = ReportStatGroup.FormatedHeader(header, topItem) };
|
||||||
Value = x.Count().ToString()
|
group.Items.AddRange(top);
|
||||||
})
|
result.Groups.Add(group);
|
||||||
);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
/// <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, ReportHelper.GetServerLocalizedString("HeaderCountries"), 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()
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
private ReportStatResult GetResultParentalRatings(ReportStatResult result, BaseItem[] items, int topItem = 5)
|
return result;
|
||||||
{
|
}
|
||||||
this.GetGroups(result, ReportHelper.GetServerLocalizedString("HeaderParentalRatings"), 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 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, ReportHelper.GetServerLocalizedString("LabelCommunityRating"), 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;
|
||||||
|
}
|
||||||
|
|
||||||
private ReportStatResult GetResultProductionYears(ReportStatResult result, BaseItem[] items, int topItem = 5)
|
/// <summary> Gets result genres. </summary>
|
||||||
{
|
/// <param name="result"> The result. </param>
|
||||||
this.GetGroups(result, ReportHelper.GetServerLocalizedString("HeaderYears"), topItem,
|
/// <param name="items"> The items. </param>
|
||||||
items.Where(x => x.ProductionYear != null && x.ProductionYear > 0)
|
/// <param name="topItem"> The top item. </param>
|
||||||
.GroupBy(x => x.ProductionYear)
|
/// <returns> The result genres. </returns>
|
||||||
.OrderByDescending(x => x.Count())
|
private ReportStatResult GetResultGenres(ReportStatResult result, BaseItem[] items, int topItem = 5)
|
||||||
.Take(topItem)
|
{
|
||||||
.Select(x => new ReportStatItem
|
this.GetGroups(result, ReportHelper.GetServerLocalizedString("HeaderGenres"), topItem,
|
||||||
{
|
items.SelectMany(x => x.Genres)
|
||||||
Name = x.Key.ToString(),
|
.GroupBy(x => x)
|
||||||
Value = x.Count().ToString()
|
.OrderByDescending(x => x.Count())
|
||||||
})
|
.Take(topItem)
|
||||||
);
|
.Select(x => new ReportStatItem
|
||||||
|
{
|
||||||
|
Name = x.Key,
|
||||||
|
Value = x.Count().ToString(),
|
||||||
|
Id = GetGenreID(x.Key)
|
||||||
|
}));
|
||||||
|
return result;
|
||||||
|
|
||||||
return result;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private ReportStatResult GetResulProductionLocations(ReportStatResult result, BaseItem[] items, int topItem = 5)
|
/// <summary> Gets result parental ratings. </summary>
|
||||||
{
|
/// <param name="result"> The result. </param>
|
||||||
this.GetGroups(result, ReportHelper.GetServerLocalizedString("HeaderCountries"), topItem,
|
/// <param name="items"> The items. </param>
|
||||||
items.OfType<IHasProductionLocations>()
|
/// <param name="topItem"> The top item. </param>
|
||||||
.Where(x => x.ProductionLocations != null)
|
/// <returns> The result parental ratings. </returns>
|
||||||
.SelectMany(x => x.ProductionLocations)
|
private ReportStatResult GetResultParentalRatings(ReportStatResult result, BaseItem[] items, int topItem = 5)
|
||||||
.GroupBy(x => x)
|
{
|
||||||
.OrderByDescending(x => x.Count())
|
this.GetGroups(result, ReportHelper.GetServerLocalizedString("HeaderParentalRatings"), topItem,
|
||||||
.Take(topItem)
|
items.Where(x => x.OfficialRating != null)
|
||||||
.Select(x => new ReportStatItem
|
.GroupBy(x => x.OfficialRating)
|
||||||
{
|
.OrderByDescending(x => x.Count())
|
||||||
Name = x.Key.ToString(),
|
.Take(topItem)
|
||||||
Value = x.Count().ToString()
|
.Select(x => new ReportStatItem
|
||||||
})
|
{
|
||||||
);
|
Name = x.Key.ToString(),
|
||||||
|
Value = x.Count().ToString()
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
return result;
|
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<string> t = new List<string> { PersonType.Actor, PersonType.Composer, PersonType.Director, PersonType.GuestStar, PersonType.Producer, PersonType.Writer, "Artist", "AlbumArtist" };
|
||||||
|
foreach (var item in t)
|
||||||
|
{
|
||||||
|
var ps = items.Where(x => x.People != null && x.SupportsPeople).SelectMany(x => x.People)
|
||||||
|
.Where(n => n.Type == item)
|
||||||
|
.GroupBy(x => x.Name)
|
||||||
|
.OrderByDescending(x => x.Count())
|
||||||
|
.Take(topItem);
|
||||||
|
if (ps != null && ps.Count() > 0)
|
||||||
|
this.GetGroups(result, ReportHelper.GetServerLocalizedString("Option" + item), topItem,
|
||||||
|
ps.Select(x => new ReportStatItem
|
||||||
|
{
|
||||||
|
Name = x.Key,
|
||||||
|
Value = x.Count().ToString(),
|
||||||
|
Id = GetPersonID(x.Key)
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary> Gets the groups. </summary>
|
return result;
|
||||||
/// <param name="result"> The result. </param>
|
}
|
||||||
/// <param name="header"> The header. </param>
|
|
||||||
/// <param name="topItem"> The top item. </param>
|
/// <summary> Gets result production years. </summary>
|
||||||
/// <param name="top"> The top. </param>
|
/// <param name="result"> The result. </param>
|
||||||
private void GetGroups(ReportStatResult result, string header, int topItem, IEnumerable<ReportStatItem> top)
|
/// <param name="items"> The items. </param>
|
||||||
{
|
/// <param name="topItem"> The top item. </param>
|
||||||
if (top.Count() > 0)
|
/// <returns> The result production years. </returns>
|
||||||
{
|
private ReportStatResult GetResultProductionYears(ReportStatResult result, BaseItem[] items, int topItem = 5)
|
||||||
var group = new ReportStatGroup { Header = ReportStatGroup.FormatedHeader(header, topItem) };
|
{
|
||||||
group.Items.AddRange(top);
|
this.GetGroups(result, ReportHelper.GetServerLocalizedString("HeaderYears"), topItem,
|
||||||
result.Groups.Add(group);
|
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, ReportHelper.GetServerLocalizedString("HeaderStudios"), 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
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1459,5 +1459,10 @@
|
||||||
"LabelUsername": "Username:",
|
"LabelUsername": "Username:",
|
||||||
"HeaderSignUp": "Sign Up",
|
"HeaderSignUp": "Sign Up",
|
||||||
"LabelPasswordConfirm": "Password (confirm):",
|
"LabelPasswordConfirm": "Password (confirm):",
|
||||||
"ButtonAddServer": "Add Server"
|
"ButtonAddServer": "Add Server",
|
||||||
|
"HeaderOverview": "Overview",
|
||||||
|
"HeaderShortOverview": "Short Overview",
|
||||||
|
"HeaderType": "Type",
|
||||||
|
"HeaderSeverity": "Severity",
|
||||||
|
"OptionReportActivities": "Activities Log"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user