parent
cae134ec7b
commit
7e8d8500f2
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Core.Datastore;
|
using NzbDrone.Core.Datastore;
|
||||||
|
@ -28,7 +29,7 @@ namespace NzbDrone.Core.SeriesStats
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!DateTime.TryParse(NextAiringString, out nextAiring))
|
if (!DateTime.TryParse(NextAiringString, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AssumeUniversal, out nextAiring))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +52,7 @@ namespace NzbDrone.Core.SeriesStats
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!DateTime.TryParse(PreviousAiringString, out previousAiring))
|
if (!DateTime.TryParse(PreviousAiringString, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AssumeUniversal, out previousAiring))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -74,7 +75,7 @@ namespace NzbDrone.Core.SeriesStats
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!DateTime.TryParse(LastAiredString, out lastAired))
|
if (!DateTime.TryParse(LastAiredString, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AssumeUniversal, out lastAired))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,83 +7,14 @@ namespace NzbDrone.Core.SeriesStats
|
||||||
public class SeriesStatistics : ResultSet
|
public class SeriesStatistics : ResultSet
|
||||||
{
|
{
|
||||||
public int SeriesId { get; set; }
|
public int SeriesId { get; set; }
|
||||||
public string NextAiringString { get; set; }
|
public DateTime? NextAiring { get; set; }
|
||||||
public string PreviousAiringString { get; set; }
|
public DateTime? PreviousAiring { get; set; }
|
||||||
public string LastAiredString { get; set; }
|
public DateTime? LastAired { get; set; }
|
||||||
public int EpisodeFileCount { get; set; }
|
public int EpisodeFileCount { get; set; }
|
||||||
public int EpisodeCount { get; set; }
|
public int EpisodeCount { get; set; }
|
||||||
public int TotalEpisodeCount { get; set; }
|
public int TotalEpisodeCount { get; set; }
|
||||||
public long SizeOnDisk { get; set; }
|
public long SizeOnDisk { get; set; }
|
||||||
public List<string> ReleaseGroups { get; set; }
|
public List<string> ReleaseGroups { get; set; }
|
||||||
public List<SeasonStatistics> SeasonStatistics { get; set; }
|
public List<SeasonStatistics> SeasonStatistics { get; set; }
|
||||||
|
|
||||||
public DateTime? NextAiring
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
DateTime nextAiring;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (!DateTime.TryParse(NextAiringString, out nextAiring))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (ArgumentOutOfRangeException)
|
|
||||||
{
|
|
||||||
// GHI 3518: Can throw on mono (6.x?) despite being a Try*
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return nextAiring;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public DateTime? PreviousAiring
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
DateTime previousAiring;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (!DateTime.TryParse(PreviousAiringString, out previousAiring))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (ArgumentOutOfRangeException)
|
|
||||||
{
|
|
||||||
// GHI 3518: Can throw on mono (6.x?) despite being a Try*
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return previousAiring;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public DateTime? LastAired
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
DateTime lastAired;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (!DateTime.TryParse(LastAiredString, out lastAired))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (ArgumentOutOfRangeException)
|
|
||||||
{
|
|
||||||
// GHI 3518: Can throw on mono (6.x?) despite being a Try*
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return lastAired;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,23 +40,23 @@ namespace NzbDrone.Core.SeriesStats
|
||||||
private SeriesStatistics MapSeriesStatistics(List<SeasonStatistics> seasonStatistics)
|
private SeriesStatistics MapSeriesStatistics(List<SeasonStatistics> seasonStatistics)
|
||||||
{
|
{
|
||||||
var seriesStatistics = new SeriesStatistics
|
var seriesStatistics = new SeriesStatistics
|
||||||
{
|
{
|
||||||
SeasonStatistics = seasonStatistics,
|
SeasonStatistics = seasonStatistics,
|
||||||
SeriesId = seasonStatistics.First().SeriesId,
|
SeriesId = seasonStatistics.First().SeriesId,
|
||||||
EpisodeFileCount = seasonStatistics.Sum(s => s.EpisodeFileCount),
|
EpisodeFileCount = seasonStatistics.Sum(s => s.EpisodeFileCount),
|
||||||
EpisodeCount = seasonStatistics.Sum(s => s.EpisodeCount),
|
EpisodeCount = seasonStatistics.Sum(s => s.EpisodeCount),
|
||||||
TotalEpisodeCount = seasonStatistics.Sum(s => s.TotalEpisodeCount),
|
TotalEpisodeCount = seasonStatistics.Sum(s => s.TotalEpisodeCount),
|
||||||
SizeOnDisk = seasonStatistics.Sum(s => s.SizeOnDisk),
|
SizeOnDisk = seasonStatistics.Sum(s => s.SizeOnDisk),
|
||||||
ReleaseGroups = seasonStatistics.SelectMany(s => s.ReleaseGroups).Distinct().ToList()
|
ReleaseGroups = seasonStatistics.SelectMany(s => s.ReleaseGroups).Distinct().ToList()
|
||||||
};
|
};
|
||||||
|
|
||||||
var nextAiring = seasonStatistics.Where(s => s.NextAiring != null).MinBy(s => s.NextAiring);
|
var nextAiring = seasonStatistics.Where(s => s.NextAiring != null).MinBy(s => s.NextAiring);
|
||||||
var previousAiring = seasonStatistics.Where(s => s.PreviousAiring != null).MaxBy(s => s.PreviousAiring);
|
var previousAiring = seasonStatistics.Where(s => s.PreviousAiring != null).MaxBy(s => s.PreviousAiring);
|
||||||
var lastAired = seasonStatistics.Where(s => s.SeasonNumber > 0 && s.LastAired != null).MaxBy(s => s.LastAired);
|
var lastAired = seasonStatistics.Where(s => s.SeasonNumber > 0 && s.LastAired != null).MaxBy(s => s.LastAired);
|
||||||
|
|
||||||
seriesStatistics.NextAiringString = nextAiring?.NextAiringString;
|
seriesStatistics.NextAiring = nextAiring?.NextAiring;
|
||||||
seriesStatistics.PreviousAiringString = previousAiring?.PreviousAiringString;
|
seriesStatistics.PreviousAiring = previousAiring?.PreviousAiring;
|
||||||
seriesStatistics.LastAiredString = lastAired?.LastAiredString;
|
seriesStatistics.LastAired = lastAired?.LastAired;
|
||||||
|
|
||||||
return seriesStatistics;
|
return seriesStatistics;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue