Fixed seriesGrid query and tests.

Fixed GetEpisodeModels that would fail due to a null AirDate.
pull/4/head
Mark McDowall 14 years ago
parent 938fa24a8e
commit 342406784a

@ -224,7 +224,7 @@ namespace NzbDrone.Core.Test
//Act
mocker.Resolve<QualityProvider>();
var series = mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount(true);
var series = mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount();
//Assert
series.Should().HaveCount(1);
@ -249,7 +249,7 @@ namespace NzbDrone.Core.Test
//Act
mocker.Resolve<QualityProvider>();
var series = mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount(true);
var series = mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount();
//Assert
series.Should().HaveCount(1);
@ -274,7 +274,7 @@ namespace NzbDrone.Core.Test
//Act
mocker.Resolve<QualityProvider>();
var series = mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount(true);
var series = mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount();
//Assert
series.Should().HaveCount(1);
@ -303,7 +303,7 @@ namespace NzbDrone.Core.Test
//Act
mocker.Resolve<QualityProvider>();
var series = mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount(true);
var series = mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount();
//Assert
series.Should().HaveCount(1);

@ -42,22 +42,21 @@ namespace NzbDrone.Core.Providers
return series;
}
public virtual IList<Series> GetAllSeriesWithEpisodeCount(bool ignoreSpecialsInSeasonCount)
public virtual IList<Series> GetAllSeriesWithEpisodeCount()
{
var seasonNumber = 0;
if (!ignoreSpecialsInSeasonCount)
seasonNumber = -1;
var series = _database
.Fetch<Series, QualityProfile>(@"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<Series, QualityProfile>(@"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;
}

@ -81,7 +81,7 @@ namespace NzbDrone.Web.Controllers
[GridAction]
public ActionResult _AjaxSeriesGrid()
{
var series = GetSeriesModels(_seriesProvider.GetAllSeriesWithEpisodeCount(true));
var series = GetSeriesModels(_seriesProvider.GetAllSeriesWithEpisodeCount());
return View(new GridModel(series));
}
@ -97,7 +97,7 @@ namespace NzbDrone.Web.Controllers
_seriesProvider.UpdateSeries(oldSeries);
var series = GetSeriesModels(_seriesProvider.GetAllSeriesWithEpisodeCount(true));
var series = GetSeriesModels(_seriesProvider.GetAllSeriesWithEpisodeCount());
return View(new GridModel(series));
}
@ -237,6 +237,11 @@ namespace NzbDrone.Web.Controllers
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 @@ namespace NzbDrone.Web.Controllers
SeasonNumber = e.SeasonNumber,
Title = e.Title,
Overview = e.Overview,
AirDate = e.AirDate.Value,
AirDate = airDate,
Path = episodePath,
EpisodeFileId = episodeFileId,
Status = e.Status.ToString(),

@ -13,8 +13,7 @@ namespace NzbDrone.Web.Models
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; }
}
}

@ -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);
})

Loading…
Cancel
Save