mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-14 11:23:42 +02:00
Fixed seriesGrid query and tests.
Fixed GetEpisodeModels that would fail due to a null AirDate.
This commit is contained in:
parent
938fa24a8e
commit
342406784a
@ -224,7 +224,7 @@ public void Get_Series_With_Count()
|
|||||||
|
|
||||||
//Act
|
//Act
|
||||||
mocker.Resolve<QualityProvider>();
|
mocker.Resolve<QualityProvider>();
|
||||||
var series = mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount(true);
|
var series = mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount();
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
series.Should().HaveCount(1);
|
series.Should().HaveCount(1);
|
||||||
@ -249,7 +249,7 @@ public void Get_Series_With_Count_AllIgnored()
|
|||||||
|
|
||||||
//Act
|
//Act
|
||||||
mocker.Resolve<QualityProvider>();
|
mocker.Resolve<QualityProvider>();
|
||||||
var series = mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount(true);
|
var series = mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount();
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
series.Should().HaveCount(1);
|
series.Should().HaveCount(1);
|
||||||
@ -274,7 +274,7 @@ public void Get_Series_With_Count_AllDownloaded()
|
|||||||
|
|
||||||
//Act
|
//Act
|
||||||
mocker.Resolve<QualityProvider>();
|
mocker.Resolve<QualityProvider>();
|
||||||
var series = mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount(true);
|
var series = mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount();
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
series.Should().HaveCount(1);
|
series.Should().HaveCount(1);
|
||||||
@ -303,7 +303,7 @@ public void Get_Series_With_Count_Half_Ignored()
|
|||||||
|
|
||||||
//Act
|
//Act
|
||||||
mocker.Resolve<QualityProvider>();
|
mocker.Resolve<QualityProvider>();
|
||||||
var series = mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount(true);
|
var series = mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount();
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
series.Should().HaveCount(1);
|
series.Should().HaveCount(1);
|
||||||
|
@ -42,22 +42,21 @@ public virtual IList<Series> GetAllSeries()
|
|||||||
return series;
|
return series;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual IList<Series> GetAllSeriesWithEpisodeCount(bool ignoreSpecialsInSeasonCount)
|
public virtual IList<Series> GetAllSeriesWithEpisodeCount()
|
||||||
{
|
{
|
||||||
var seasonNumber = 0;
|
|
||||||
|
|
||||||
if (!ignoreSpecialsInSeasonCount)
|
|
||||||
seasonNumber = -1;
|
|
||||||
|
|
||||||
var series = _database
|
var series = _database
|
||||||
.Fetch<Series, QualityProfile>(@"SELECT Series.*, SUM(CASE WHEN Ignored = 0 THEN 1 ELSE 0 END) AS EpisodeCount,
|
.Fetch<Series, QualityProfile>(@"SELECT Series.SeriesId, Series.Title, Series.CleanTitle, Series.Status, Series.Overview, Series.AirsDayOfWeek,Series.AirTimes,
|
||||||
SUM(CASE WHEN Ignored = 0 AND EpisodeFileId > 0 THEN 1 ELSE 0 END) as EpisodeFileCount,
|
Series.Language, Series.Path, Series.Monitored, Series.QualityProfileId, Series.SeasonFolder,
|
||||||
COUNT (DISTINCT(CASE WHEN SeasonNumber = 0 THEN null ELSE SeasonNumber END)) as SeasonCount,
|
SUM(CASE WHEN Ignored = 0 THEN 1 ELSE 0 END) AS EpisodeCount,
|
||||||
QualityProfiles.*
|
SUM(CASE WHEN Episodes.Ignored = 0 AND Episodes.EpisodeFileId > 0 THEN 1 ELSE 0 END) as EpisodeFileCount,
|
||||||
FROM Series
|
MAX(Episodes.SeasonNumber) as SeasonCount,
|
||||||
INNER JOIN QualityProfiles ON Series.QualityProfileId = QualityProfiles.QualityProfileId
|
QualityProfiles.QualityProfileId, QualityProfiles.Name, QualityProfiles.Cutoff, QualityProfiles.SonicAllowed
|
||||||
JOIN Episodes ON Series.SeriesId = Episodes.SeriesId
|
FROM Series
|
||||||
GROUP BY seriesId");
|
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;
|
return series;
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ public ActionResult GetSingleSeasonView(SeasonEditModel model)
|
|||||||
[GridAction]
|
[GridAction]
|
||||||
public ActionResult _AjaxSeriesGrid()
|
public ActionResult _AjaxSeriesGrid()
|
||||||
{
|
{
|
||||||
var series = GetSeriesModels(_seriesProvider.GetAllSeriesWithEpisodeCount(true));
|
var series = GetSeriesModels(_seriesProvider.GetAllSeriesWithEpisodeCount());
|
||||||
return View(new GridModel(series));
|
return View(new GridModel(series));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ public ActionResult _SaveAjaxSeriesEditing(int id, string path, bool monitored,
|
|||||||
|
|
||||||
_seriesProvider.UpdateSeries(oldSeries);
|
_seriesProvider.UpdateSeries(oldSeries);
|
||||||
|
|
||||||
var series = GetSeriesModels(_seriesProvider.GetAllSeriesWithEpisodeCount(true));
|
var series = GetSeriesModels(_seriesProvider.GetAllSeriesWithEpisodeCount());
|
||||||
return View(new GridModel(series));
|
return View(new GridModel(series));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,6 +237,11 @@ private List<EpisodeModel> GetEpisodeModels(IList<Episode> episodesInDb)
|
|||||||
episodeQuality = e.EpisodeFile.Quality.ToString();
|
episodeQuality = e.EpisodeFile.Quality.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var airDate = String.Empty;
|
||||||
|
|
||||||
|
if (e.AirDate != null)
|
||||||
|
airDate = e.AirDate.Value.ToShortDateString();
|
||||||
|
|
||||||
episodes.Add(new EpisodeModel
|
episodes.Add(new EpisodeModel
|
||||||
{
|
{
|
||||||
EpisodeId = e.EpisodeId,
|
EpisodeId = e.EpisodeId,
|
||||||
@ -244,7 +249,7 @@ private List<EpisodeModel> GetEpisodeModels(IList<Episode> episodesInDb)
|
|||||||
SeasonNumber = e.SeasonNumber,
|
SeasonNumber = e.SeasonNumber,
|
||||||
Title = e.Title,
|
Title = e.Title,
|
||||||
Overview = e.Overview,
|
Overview = e.Overview,
|
||||||
AirDate = e.AirDate.Value,
|
AirDate = airDate,
|
||||||
Path = episodePath,
|
Path = episodePath,
|
||||||
EpisodeFileId = episodeFileId,
|
EpisodeFileId = episodeFileId,
|
||||||
Status = e.Status.ToString(),
|
Status = e.Status.ToString(),
|
||||||
|
@ -13,8 +13,7 @@ public class EpisodeModel
|
|||||||
public string Overview { get; set; }
|
public string Overview { get; set; }
|
||||||
public string Path { get; set; }
|
public string Path { get; set; }
|
||||||
public String Status { get; set; }
|
public String Status { get; set; }
|
||||||
public DateTime AirDate { get; set; }
|
public string AirDate { get; set; }
|
||||||
|
|
||||||
public String Quality { get; set; }
|
public String Quality { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -61,7 +61,7 @@
|
|||||||
|
|
||||||
columns.Bound(c => c.EpisodeNumber).Width(0).Title("Episode");
|
columns.Bound(c => c.EpisodeNumber).Width(0).Title("Episode");
|
||||||
columns.Bound(c => c.Title).Title("Title");
|
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.Quality).Width(0);
|
||||||
columns.Bound(c => c.Status).Width(0);
|
columns.Bound(c => c.Status).Width(0);
|
||||||
columns.Bound(o => o.EpisodeId).Title("")
|
columns.Bound(o => o.EpisodeId).Title("")
|
||||||
@ -111,7 +111,7 @@
|
|||||||
|
|
||||||
columns.Bound(c => c.EpisodeNumber).Width(10).Title("Episode");
|
columns.Bound(c => c.EpisodeNumber).Width(10).Title("Episode");
|
||||||
columns.Bound(c => c.Title).Title("Title").Width(10000);
|
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.Quality).Width(10);
|
||||||
columns.Bound(c => c.Status).Width(10);
|
columns.Bound(c => c.Status).Width(10);
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user