2017-02-11 06:46:39 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using NzbDrone.Core.SeriesStats;
|
|
|
|
|
|
|
|
namespace Sonarr.Api.V3.Series
|
|
|
|
{
|
|
|
|
public class SeriesStatisticsResource
|
|
|
|
{
|
|
|
|
public int SeasonCount { get; set; }
|
|
|
|
public int EpisodeFileCount { get; set; }
|
|
|
|
public int EpisodeCount { get; set; }
|
|
|
|
public int TotalEpisodeCount { get; set; }
|
|
|
|
public long SizeOnDisk { get; set; }
|
2022-02-27 09:18:13 +00:00
|
|
|
public List<string> ReleaseGroups { get; set; }
|
2017-02-11 06:46:39 +00:00
|
|
|
|
|
|
|
public decimal PercentOfEpisodes
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2021-08-03 04:43:28 +00:00
|
|
|
if (EpisodeCount == 0)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2017-02-11 06:46:39 +00:00
|
|
|
|
|
|
|
return (decimal)EpisodeFileCount / (decimal)EpisodeCount * 100;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class SeriesStatisticsResourceMapper
|
|
|
|
{
|
|
|
|
public static SeriesStatisticsResource ToResource(this SeriesStatistics model, List<SeasonResource> seasons)
|
|
|
|
{
|
2021-08-03 04:43:28 +00:00
|
|
|
if (model == null)
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
2017-02-11 06:46:39 +00:00
|
|
|
|
|
|
|
return new SeriesStatisticsResource
|
|
|
|
{
|
|
|
|
SeasonCount = seasons == null ? 0 : seasons.Where(s => s.SeasonNumber > 0).Count(),
|
|
|
|
EpisodeFileCount = model.EpisodeFileCount,
|
|
|
|
EpisodeCount = model.EpisodeCount,
|
|
|
|
TotalEpisodeCount = model.TotalEpisodeCount,
|
2022-02-27 09:18:13 +00:00
|
|
|
SizeOnDisk = model.SizeOnDisk,
|
|
|
|
ReleaseGroups = model.ReleaseGroups
|
2017-02-11 06:46:39 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|