Beispiel #1
0
        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)
            {
                this.GetGroups(result, ReportHelper.GetServerLocalizedString("Option" + item), topItem,
                               items.SelectMany(x => x.People)
                               .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);
        }
Beispiel #2
0
 /// <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.Count() > 0)
     {
         var group = new ReportStatGroup {
             Header = ReportStatGroup.FormatedHeader(header, topItem)
         };
         group.Items.AddRange(top);
         result.Groups.Add(group);
     }
 }
Beispiel #3
0
        /// <summary> Gets report statistic. </summary>
        /// <param name="request"> The request. </param>
        /// <returns> The report statistic. </returns>
        private async Task <ReportStatResult> GetReportStatistic(GetReportStatistics request)
        {
            ReportIncludeItemTypes reportRowType = ReportHelper.GetRowType(request.IncludeItemTypes);
            QueryResult <BaseItem> queryResult   = await GetQueryResult(request).ConfigureAwait(false);

            ReportStatBuilder reportBuilder = new ReportStatBuilder(_libraryManager);
            ReportStatResult  reportResult  = reportBuilder.GetResult(queryResult.Items, ReportHelper.GetRowType(request.IncludeItemTypes), request.TopItems ?? 5);

            reportResult.TotalRecordCount = reportResult.Groups.Count();
            return(reportResult);
        }
Beispiel #4
0
 private ReportStatResult GetResultGenres(ReportStatResult result, BaseItem[] items, int topItem = 5)
 {
     this.GetGroups(result, ReportHelper.GetServerLocalizedString("HeaderGenres"), 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);
 }
Beispiel #5
0
        /// <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);
        }
		private ReportStatResult GetResultGenres(ReportStatResult result, BaseItem[] items, int topItem = 5)
		{
			this.GetGroups(result, ReportHelper.GetServerLocalizedString("HeaderGenres"), 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;

		}
Beispiel #7
0
        private ReportStatResult GetResultParentalRatings(ReportStatResult result, BaseItem[] items, int topItem = 5)
        {
            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);
        }
Beispiel #8
0
        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);
        }
Beispiel #9
0
        /// <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);
        }
Beispiel #10
0
        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()
            })
                           );

            return(result);
        }
Beispiel #11
0
        /// <summary> Gets report stat result. </summary>
        /// <param name="items"> The items. </param>
        /// <param name="reportRowType"> Type of the report row. </param>
        /// <param name="topItem"> The top item. </param>
        /// <returns> The report stat result. </returns>
        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)
            {
            case ReportViewType.Season:
            case ReportViewType.Series:
            case ReportViewType.MusicAlbum:
            case ReportViewType.MusicArtist:
            case ReportViewType.Game:
                break;

            case ReportViewType.Movie:
            case ReportViewType.BoxSet:

                break;

            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();

            return(result);
        }
		/// <summary> Gets report stat result. </summary>
		/// <param name="items"> The items. </param>
		/// <param name="reportRowType"> Type of the report row. </param>
		/// <param name="topItem"> The top item. </param>
		/// <returns> The report stat result. </returns>
		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)
			{
				case ReportViewType.Season:
				case ReportViewType.Series:
				case ReportViewType.MusicAlbum:
				case ReportViewType.MusicArtist:
				case ReportViewType.Game:
					break;
				case ReportViewType.Movie:
				case ReportViewType.BoxSet:

					break;
				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();

			return result;
		}
Beispiel #13
0
        /// <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.Where(x => x.People != null && x.SupportsPeople).SelectMany(x => x.People)
                         .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);
        }
		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)
			{
				this.GetGroups(result, ReportHelper.GetServerLocalizedString("Option" + item), topItem,
						items.SelectMany(x => x.People)
								.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;
		}
		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;
		}
		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()
						})
			);

			return result;
		}
		/// <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.Count() > 0)
			{
				var group = new ReportStatGroup { Header = ReportStatGroup.FormatedHeader(header, topItem) };
				group.Items.AddRange(top);
				result.Groups.Add(group);
			}
		}
		private ReportStatResult GetResultParentalRatings(ReportStatResult result, BaseItem[] items, int topItem = 5)
		{
			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;
		}