SeriesStats are returned when fetching a single series

SeriesStats are no longer wipred from UI on update
pull/4/head
Mark McDowall 11 years ago
parent a9dd2d2f04
commit 19b3add783

@ -75,6 +75,8 @@ namespace NzbDrone.Api.Series
var resource = series.InjectTo<SeriesResource>(); var resource = series.InjectTo<SeriesResource>();
MapCoversToLocal(resource); MapCoversToLocal(resource);
LinkSeriesStatistics(resource, _seriesStatisticsService.SeriesStatistics());
return resource; return resource;
} }
@ -83,15 +85,9 @@ namespace NzbDrone.Api.Series
var seriesStats = _seriesStatisticsService.SeriesStatistics(); var seriesStats = _seriesStatisticsService.SeriesStatistics();
var seriesResources = ToListResource(_seriesService.GetAllSeries); var seriesResources = ToListResource(_seriesService.GetAllSeries);
foreach (var s in seriesResources) foreach (var resource in seriesResources)
{ {
var stats = seriesStats.SingleOrDefault(ss => ss.SeriesId == s.Id); LinkSeriesStatistics(resource, seriesStats);
if (stats == null) continue;
s.EpisodeCount = stats.EpisodeCount;
s.EpisodeFileCount = stats.EpisodeFileCount;
s.SeasonCount = stats.SeasonCount;
s.NextAiring = stats.NextAiring;
} }
MapCoversToLocal(seriesResources.ToArray()); MapCoversToLocal(seriesResources.ToArray());
@ -99,8 +95,6 @@ namespace NzbDrone.Api.Series
return seriesResources; return seriesResources;
} }
private SeriesResource AddSeries(SeriesResource seriesResource) private SeriesResource AddSeries(SeriesResource seriesResource)
{ {
return ToResource<Core.Tv.Series>(_seriesService.AddSeries, seriesResource); return ToResource<Core.Tv.Series>(_seriesService.AddSeries, seriesResource);
@ -108,7 +102,11 @@ namespace NzbDrone.Api.Series
private SeriesResource UpdateSeries(SeriesResource seriesResource) private SeriesResource UpdateSeries(SeriesResource seriesResource)
{ {
return ToResource<Core.Tv.Series>(_seriesService.UpdateSeries, seriesResource); var resource = ToResource<Core.Tv.Series>(_seriesService.UpdateSeries, seriesResource);
MapCoversToLocal(resource);
LinkSeriesStatistics(resource, _seriesStatisticsService.SeriesStatistics());
return resource;
} }
private void DeleteSeries(int id) private void DeleteSeries(int id)
@ -124,6 +122,16 @@ namespace NzbDrone.Api.Series
_coverMapper.ConvertToLocalUrls(seriesResource.Id, seriesResource.Images); _coverMapper.ConvertToLocalUrls(seriesResource.Id, seriesResource.Images);
} }
} }
}
private void LinkSeriesStatistics(SeriesResource resource, List<SeriesStatistics> seriesStatistics)
{
var stats = seriesStatistics.SingleOrDefault(ss => ss.SeriesId == resource.Id);
if (stats == null) return;
resource.EpisodeCount = stats.EpisodeCount;
resource.EpisodeFileCount = stats.EpisodeFileCount;
resource.SeasonCount = stats.SeasonCount;
resource.NextAiring = stats.NextAiring;
}
}
} }

@ -1,4 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
namespace NzbDrone.Core.SeriesStats namespace NzbDrone.Core.SeriesStats
{ {

Loading…
Cancel
Save