Reports - icons and people fix

pull/702/head
Tavares André 9 years ago
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> /// <summary>
public ReportStatBuilder(ILibraryManager libraryManager) /// Initializes a new instance of the MediaBrowser.Api.Reports.ReportStatBuilder class. </summary>
: base(libraryManager) /// <param name="libraryManager"> Manager for library. </param>
{ public ReportStatBuilder(ILibraryManager libraryManager)
} : base(libraryManager)
{
/// <summary> Gets report stat result. </summary> }
/// <param name="items"> The items. </param>
/// <param name="reportRowType"> Type of the report row. </param> #endregion
/// <param name="topItem"> The top item. </param>
/// <returns> The report stat result. </returns> #region [Public Methods]
public ReportStatResult GetReportStatResult(BaseItem[] items, ReportViewType reportRowType, int topItem = 5)
{ /// <summary> Gets report stat result. </summary>
ReportStatResult result = new ReportStatResult(); /// <param name="items"> The items. </param>
result = this.GetResultGenres(result, items, topItem); /// <param name="reportIncludeItemTypes"> List of types of the report include items. </param>
result = this.GetResultStudios(result, items, topItem); /// <param name="topItem"> The top item. </param>
result = this.GetResultPersons(result, items, topItem); /// <returns> The report stat result. </returns>
result = this.GetResultProductionYears(result, items, topItem); public ReportStatResult GetResult(BaseItem[] items, ReportIncludeItemTypes reportIncludeItemTypes, int topItem = 5)
result = this.GetResulProductionLocations(result, items, topItem); {
result = this.GetResultCommunityRatings(result, items, topItem); ReportStatResult result = new ReportStatResult();
result = this.GetResultParentalRatings(result, items, topItem); result = this.GetResultGenres(result, items, topItem);
result = this.GetResultStudios(result, items, topItem);
switch (reportRowType) result = this.GetResultPersons(result, items, topItem);
{ result = this.GetResultProductionYears(result, items, topItem);
case ReportViewType.Season: result = this.GetResulProductionLocations(result, items, topItem);
case ReportViewType.Series: result = this.GetResultCommunityRatings(result, items, topItem);
case ReportViewType.MusicAlbum: result = this.GetResultParentalRatings(result, items, topItem);
case ReportViewType.MusicArtist:
case ReportViewType.Game: switch (reportIncludeItemTypes)
break; {
case ReportViewType.Movie: case ReportIncludeItemTypes.Season:
case ReportViewType.BoxSet: case ReportIncludeItemTypes.Series:
case ReportIncludeItemTypes.MusicAlbum:
break; case ReportIncludeItemTypes.MusicArtist:
case ReportViewType.Book: case ReportIncludeItemTypes.Game:
case ReportViewType.Episode: break;
case ReportViewType.Video: case ReportIncludeItemTypes.Movie:
case ReportViewType.MusicVideo: case ReportIncludeItemTypes.BoxSet:
case ReportViewType.Trailer:
case ReportViewType.Audio: break;
case ReportViewType.BaseItem: case ReportIncludeItemTypes.Book:
default: case ReportIncludeItemTypes.Episode:
break; case ReportIncludeItemTypes.Video:
} case ReportIncludeItemTypes.MusicVideo:
case ReportIncludeItemTypes.Trailer:
result.Groups = result.Groups.OrderByDescending(n => n.Items.Count()).ToList(); case ReportIncludeItemTypes.Audio:
case ReportIncludeItemTypes.BaseItem:
return result; default:
} break;
}
private ReportStatResult GetResultGenres(ReportStatResult result, BaseItem[] items, int topItem = 5)
{ result.Groups = result.Groups.OrderByDescending(n => n.Items.Count()).ToList();
this.GetGroups(result, ReportHelper.GetServerLocalizedString("HeaderGenres"), topItem,
items.SelectMany(x => x.Genres) return result;
.GroupBy(x => x) }
.OrderByDescending(x => x.Count())
.Take(topItem) #endregion
.Select(x => new ReportStatItem
{ #region [Protected Internal Methods]
Name = x.Key, /// <summary> Gets the headers. </summary>
Value = x.Count().ToString(), /// <typeparam name="H"> Type of the header. </typeparam>
Id = GetGenreID(x.Key) /// <param name="request"> The request. </param>
})); /// <returns> The headers. </returns>
return result; /// <seealso cref="M:MediaBrowser.Api.Reports.ReportBuilderBase.GetHeaders{H}(H)"/>
protected internal override List<ReportHeader> GetHeaders<H>(H request)
} {
throw new NotImplementedException();
private ReportStatResult GetResultStudios(ReportStatResult result, BaseItem[] items, int topItem = 5) }
{
this.GetGroups(result, ReportHelper.GetServerLocalizedString("HeaderStudios"), topItem, #endregion
items.SelectMany(x => x.Studios)
.GroupBy(x => x) #region [Private Methods]
.OrderByDescending(x => x.Count())
.Take(topItem) /// <summary> Gets the groups. </summary>
.Select(x => new ReportStatItem /// <param name="result"> The result. </param>
{ /// <param name="header"> The header. </param>
Name = x.Key, /// <param name="topItem"> The top item. </param>
Value = x.Count().ToString(), /// <param name="top"> The top. </param>
Id = GetStudioID(x.Key) private void GetGroups(ReportStatResult result, string header, int topItem, IEnumerable<ReportStatItem> top)
}) {
); if (top != null && top.Count() > 0)
{
return result; var group = new ReportStatGroup { Header = ReportStatGroup.FormatedHeader(header, topItem) };
group.Items.AddRange(top);
} result.Groups.Add(group);
}
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" }; /// <summary> Gets resul production locations. </summary>
foreach (var item in t) /// <param name="result"> The result. </param>
{ /// <param name="items"> The items. </param>
this.GetGroups(result, ReportHelper.GetServerLocalizedString("Option" + item), topItem, /// <param name="topItem"> The top item. </param>
items.SelectMany(x => _libraryManager.GetPeople(x)) /// <returns> The resul production locations. </returns>
.Where(n => n.Type == item) private ReportStatResult GetResulProductionLocations(ReportStatResult result, BaseItem[] items, int topItem = 5)
.GroupBy(x => x.Name) {
.OrderByDescending(x => x.Count()) this.GetGroups(result, ReportHelper.GetServerLocalizedString("HeaderCountries"), topItem,
.Take(topItem) items.OfType<IHasProductionLocations>()
.Select(x => new ReportStatItem .Where(x => x.ProductionLocations != null)
{ .SelectMany(x => x.ProductionLocations)
Name = x.Key, .GroupBy(x => x)
Value = x.Count().ToString(), .OrderByDescending(x => x.Count())
Id = GetPersonID(x.Key) .Take(topItem)
}) .Select(x => new ReportStatItem
); {
} Name = x.Key.ToString(),
Value = x.Count().ToString()
return result; })
} );
private ReportStatResult GetResultCommunityRatings(ReportStatResult result, BaseItem[] items, int topItem = 5) return result;
{ }
this.GetGroups(result, ReportHelper.GetServerLocalizedString("LabelCommunityRating"), topItem,
items.Where(x => x.CommunityRating != null && x.CommunityRating > 0) /// <summary> Gets result community ratings. </summary>
.GroupBy(x => x.CommunityRating) /// <param name="result"> The result. </param>
.OrderByDescending(x => x.Count()) /// <param name="items"> The items. </param>
.Take(topItem) /// <param name="topItem"> The top item. </param>
.Select(x => new ReportStatItem /// <returns> The result community ratings. </returns>
{ private ReportStatResult GetResultCommunityRatings(ReportStatResult result, BaseItem[] items, int topItem = 5)
Name = x.Key.ToString(), {
Value = x.Count().ToString() this.GetGroups(result, ReportHelper.GetServerLocalizedString("LabelCommunityRating"), topItem,
}) items.Where(x => x.CommunityRating != null && x.CommunityRating > 0)
); .GroupBy(x => x.CommunityRating)
.OrderByDescending(x => x.Count())
return result; .Take(topItem)
} .Select(x => new ReportStatItem
{
private ReportStatResult GetResultParentalRatings(ReportStatResult result, BaseItem[] items, int topItem = 5) Name = x.Key.ToString(),
{ Value = x.Count().ToString()
this.GetGroups(result, ReportHelper.GetServerLocalizedString("HeaderParentalRatings"), topItem, })
items.Where(x => x.OfficialRating != null) );
.GroupBy(x => x.OfficialRating)
.OrderByDescending(x => x.Count()) return result;
.Take(topItem) }
.Select(x => new ReportStatItem
{ /// <summary> Gets result genres. </summary>
Name = x.Key.ToString(), /// <param name="result"> The result. </param>
Value = x.Count().ToString() /// <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)
return result; {
} this.GetGroups(result, ReportHelper.GetServerLocalizedString("HeaderGenres"), topItem,
items.SelectMany(x => x.Genres)
.GroupBy(x => x)
private ReportStatResult GetResultProductionYears(ReportStatResult result, BaseItem[] items, int topItem = 5) .OrderByDescending(x => x.Count())
{ .Take(topItem)
this.GetGroups(result, ReportHelper.GetServerLocalizedString("HeaderYears"), topItem, .Select(x => new ReportStatItem
items.Where(x => x.ProductionYear != null && x.ProductionYear > 0) {
.GroupBy(x => x.ProductionYear) Name = x.Key,
.OrderByDescending(x => x.Count()) Value = x.Count().ToString(),
.Take(topItem) Id = GetGenreID(x.Key)
.Select(x => new ReportStatItem }));
{ return result;
Name = x.Key.ToString(),
Value = x.Count().ToString() }
})
); /// <summary> Gets result parental ratings. </summary>
/// <param name="result"> The result. </param>
return result; /// <param name="items"> The items. </param>
} /// <param name="topItem"> The top item. </param>
/// <returns> The result parental ratings. </returns>
private ReportStatResult GetResulProductionLocations(ReportStatResult result, BaseItem[] items, int topItem = 5) private ReportStatResult GetResultParentalRatings(ReportStatResult result, BaseItem[] items, int topItem = 5)
{ {
this.GetGroups(result, ReportHelper.GetServerLocalizedString("HeaderCountries"), topItem, this.GetGroups(result, ReportHelper.GetServerLocalizedString("HeaderParentalRatings"), topItem,
items.OfType<IHasProductionLocations>() items.Where(x => x.OfficialRating != null)
.Where(x => x.ProductionLocations != null) .GroupBy(x => x.OfficialRating)
.SelectMany(x => x.ProductionLocations) .OrderByDescending(x => x.Count())
.GroupBy(x => x) .Take(topItem)
.OrderByDescending(x => x.Count()) .Select(x => new ReportStatItem
.Take(topItem) {
.Select(x => new ReportStatItem Name = x.Key.ToString(),
{ Value = x.Count().ToString()
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>
/// <summary> Gets the groups. </summary> /// <param name="topItem"> The top item. </param>
/// <param name="result"> The result. </param> /// <returns> The result persons. </returns>
/// <param name="header"> The header. </param> private ReportStatResult GetResultPersons(ReportStatResult result, BaseItem[] items, int topItem = 5)
/// <param name="topItem"> The top item. </param> {
/// <param name="top"> The top. </param> List<string> t = new List<string> { PersonType.Actor, PersonType.Composer, PersonType.Director, PersonType.GuestStar, PersonType.Producer, PersonType.Writer, "Artist", "AlbumArtist" };
private void GetGroups(ReportStatResult result, string header, int topItem, IEnumerable<ReportStatItem> top) foreach (var item in t)
{ {
if (top.Count() > 0) var ps = items.Where(x => x.People != null && x.SupportsPeople).SelectMany(x => x.People)
{ .Where(n => n.Type == item)
var group = new ReportStatGroup { Header = ReportStatGroup.FormatedHeader(header, topItem) }; .GroupBy(x => x.Name)
group.Items.AddRange(top); .OrderByDescending(x => x.Count())
result.Groups.Add(group); .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)
})
);
}
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, ReportHelper.GetServerLocalizedString("HeaderYears"), 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, 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…
Cancel
Save