diff --git a/NzbDrone.Core.Test/SeriesProviderTest.cs b/NzbDrone.Core.Test/SeriesProviderTest.cs index 2b032aa00..f04eae442 100644 --- a/NzbDrone.Core.Test/SeriesProviderTest.cs +++ b/NzbDrone.Core.Test/SeriesProviderTest.cs @@ -224,7 +224,7 @@ public void Get_Series_With_Count() //Act mocker.Resolve(); - var series = mocker.Resolve().GetAllSeriesWithEpisodeCount(true); + var series = mocker.Resolve().GetAllSeriesWithEpisodeCount(); //Assert series.Should().HaveCount(1); @@ -249,7 +249,7 @@ public void Get_Series_With_Count_AllIgnored() //Act mocker.Resolve(); - var series = mocker.Resolve().GetAllSeriesWithEpisodeCount(true); + var series = mocker.Resolve().GetAllSeriesWithEpisodeCount(); //Assert series.Should().HaveCount(1); @@ -274,7 +274,7 @@ public void Get_Series_With_Count_AllDownloaded() //Act mocker.Resolve(); - var series = mocker.Resolve().GetAllSeriesWithEpisodeCount(true); + var series = mocker.Resolve().GetAllSeriesWithEpisodeCount(); //Assert series.Should().HaveCount(1); @@ -303,7 +303,7 @@ public void Get_Series_With_Count_Half_Ignored() //Act mocker.Resolve(); - var series = mocker.Resolve().GetAllSeriesWithEpisodeCount(true); + var series = mocker.Resolve().GetAllSeriesWithEpisodeCount(); //Assert series.Should().HaveCount(1); diff --git a/NzbDrone.Core/Providers/SeriesProvider.cs b/NzbDrone.Core/Providers/SeriesProvider.cs index 5bb78ed60..8d0ec18fd 100644 --- a/NzbDrone.Core/Providers/SeriesProvider.cs +++ b/NzbDrone.Core/Providers/SeriesProvider.cs @@ -42,22 +42,21 @@ public virtual IList GetAllSeries() return series; } - public virtual IList GetAllSeriesWithEpisodeCount(bool ignoreSpecialsInSeasonCount) + public virtual IList GetAllSeriesWithEpisodeCount() { - var seasonNumber = 0; - - if (!ignoreSpecialsInSeasonCount) - seasonNumber = -1; - var series = _database - .Fetch(@"SELECT Series.*, SUM(CASE WHEN Ignored = 0 THEN 1 ELSE 0 END) AS EpisodeCount, -SUM(CASE WHEN Ignored = 0 AND EpisodeFileId > 0 THEN 1 ELSE 0 END) as EpisodeFileCount, -COUNT (DISTINCT(CASE WHEN SeasonNumber = 0 THEN null ELSE SeasonNumber END)) as SeasonCount, -QualityProfiles.* -FROM Series -INNER JOIN QualityProfiles ON Series.QualityProfileId = QualityProfiles.QualityProfileId -JOIN Episodes ON Series.SeriesId = Episodes.SeriesId -GROUP BY seriesId"); + .Fetch(@"SELECT Series.SeriesId, Series.Title, Series.CleanTitle, Series.Status, Series.Overview, Series.AirsDayOfWeek,Series.AirTimes, + Series.Language, Series.Path, Series.Monitored, Series.QualityProfileId, Series.SeasonFolder, + SUM(CASE WHEN Ignored = 0 THEN 1 ELSE 0 END) AS EpisodeCount, + SUM(CASE WHEN Episodes.Ignored = 0 AND Episodes.EpisodeFileId > 0 THEN 1 ELSE 0 END) as EpisodeFileCount, + MAX(Episodes.SeasonNumber) as SeasonCount, + QualityProfiles.QualityProfileId, QualityProfiles.Name, QualityProfiles.Cutoff, QualityProfiles.SonicAllowed + FROM Series + INNER JOIN QualityProfiles ON Series.QualityProfileId = QualityProfiles.QualityProfileId + LEFT JOIN Episodes ON Series.SeriesId = Episodes.SeriesId + GROUP BY Series.SeriesId, Series.Title, Series.CleanTitle, Series.Status, Series.Overview, Series.AirsDayOfWeek,Series.AirTimes, + Series.Language, Series.Path, Series.Monitored, Series.QualityProfileId, Series.SeasonFolder, + QualityProfiles.QualityProfileId, QualityProfiles.Name, QualityProfiles.Cutoff, QualityProfiles.SonicAllowed"); return series; } diff --git a/NzbDrone.Web/Controllers/SeriesController.cs b/NzbDrone.Web/Controllers/SeriesController.cs index 19feffe71..1dbb80a99 100644 --- a/NzbDrone.Web/Controllers/SeriesController.cs +++ b/NzbDrone.Web/Controllers/SeriesController.cs @@ -81,7 +81,7 @@ public ActionResult GetSingleSeasonView(SeasonEditModel model) [GridAction] public ActionResult _AjaxSeriesGrid() { - var series = GetSeriesModels(_seriesProvider.GetAllSeriesWithEpisodeCount(true)); + var series = GetSeriesModels(_seriesProvider.GetAllSeriesWithEpisodeCount()); return View(new GridModel(series)); } @@ -97,7 +97,7 @@ public ActionResult _SaveAjaxSeriesEditing(int id, string path, bool monitored, _seriesProvider.UpdateSeries(oldSeries); - var series = GetSeriesModels(_seriesProvider.GetAllSeriesWithEpisodeCount(true)); + var series = GetSeriesModels(_seriesProvider.GetAllSeriesWithEpisodeCount()); return View(new GridModel(series)); } @@ -237,6 +237,11 @@ private List GetEpisodeModels(IList episodesInDb) episodeQuality = e.EpisodeFile.Quality.ToString(); } + var airDate = String.Empty; + + if (e.AirDate != null) + airDate = e.AirDate.Value.ToShortDateString(); + episodes.Add(new EpisodeModel { EpisodeId = e.EpisodeId, @@ -244,7 +249,7 @@ private List GetEpisodeModels(IList episodesInDb) SeasonNumber = e.SeasonNumber, Title = e.Title, Overview = e.Overview, - AirDate = e.AirDate.Value, + AirDate = airDate, Path = episodePath, EpisodeFileId = episodeFileId, Status = e.Status.ToString(), diff --git a/NzbDrone.Web/Models/EpisodeModel.cs b/NzbDrone.Web/Models/EpisodeModel.cs index 5da326f1b..2384031d9 100644 --- a/NzbDrone.Web/Models/EpisodeModel.cs +++ b/NzbDrone.Web/Models/EpisodeModel.cs @@ -13,8 +13,7 @@ public class EpisodeModel public string Overview { get; set; } public string Path { get; set; } public String Status { get; set; } - public DateTime AirDate { get; set; } - + public string AirDate { get; set; } public String Quality { get; set; } } } \ No newline at end of file diff --git a/NzbDrone.Web/Views/Series/Details.cshtml b/NzbDrone.Web/Views/Series/Details.cshtml index a2fb68d53..c143650f2 100644 --- a/NzbDrone.Web/Views/Series/Details.cshtml +++ b/NzbDrone.Web/Views/Series/Details.cshtml @@ -61,7 +61,7 @@ columns.Bound(c => c.EpisodeNumber).Width(0).Title("Episode"); columns.Bound(c => c.Title).Title("Title"); - columns.Bound(c => c.AirDate).Format("{0:d}").Width(0); + columns.Bound(c => c.AirDate).Width(0); columns.Bound(c => c.Quality).Width(0); columns.Bound(c => c.Status).Width(0); columns.Bound(o => o.EpisodeId).Title("") @@ -111,7 +111,7 @@ columns.Bound(c => c.EpisodeNumber).Width(10).Title("Episode"); columns.Bound(c => c.Title).Title("Title").Width(10000); - columns.Bound(c => c.AirDate).Format("{0:d}").Width(10); + columns.Bound(c => c.AirDate).Width(10); columns.Bound(c => c.Quality).Width(10); columns.Bound(c => c.Status).Width(10); })