mirror of
https://github.com/lidarr/Lidarr
synced 2024-12-25 01:02:05 +00:00
AJax load episode count to keep initial loading time of Series Grid.
This commit is contained in:
parent
681353de3c
commit
467ed51432
2 changed files with 36 additions and 11 deletions
|
@ -133,6 +133,21 @@ public ActionResult _AjaxSeasonGrid(int seasonId)
|
||||||
return View(new GridModel(episodes));
|
return View(new GridModel(episodes));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JsonResult GetEpisodeCount(int seriesId)
|
||||||
|
{
|
||||||
|
var series = _seriesProvider.GetSeries(seriesId);
|
||||||
|
|
||||||
|
var monitoredSeasons = series.Seasons.Where(e => e.Monitored).Select(e => e.SeasonId);
|
||||||
|
var episodeTotal = series.Episodes.Where(e => monitoredSeasons.Contains(e.SeasonId) && e.AirDate <= DateTime.Today && e.AirDate > new DateTime(1899, 12, 31));
|
||||||
|
var episodes = episodeTotal.Where(e => e.EpisodeFileId > 0);
|
||||||
|
|
||||||
|
return Json(new
|
||||||
|
{
|
||||||
|
Episodes = episodes.Count(),
|
||||||
|
EpisodeTotal = episodeTotal.Count()
|
||||||
|
}, JsonRequestBehavior.AllowGet);
|
||||||
|
}
|
||||||
|
|
||||||
//Local Helpers
|
//Local Helpers
|
||||||
private string GetEpisodePath(EpisodeFile file)
|
private string GetEpisodePath(EpisodeFile file)
|
||||||
{
|
{
|
||||||
|
@ -237,8 +252,6 @@ private List<SeriesModel> GetSeriesModels(List<Series> seriesInDb)
|
||||||
|
|
||||||
foreach (var s in seriesInDb)
|
foreach (var s in seriesInDb)
|
||||||
{
|
{
|
||||||
var episodesTotal = s.Episodes.Where(e => e.AirDate <= DateTime.Today && e.AirDate > new DateTime(1899, 12, 31));
|
|
||||||
|
|
||||||
series.Add(new SeriesModel
|
series.Add(new SeriesModel
|
||||||
{
|
{
|
||||||
SeriesId = s.SeriesId,
|
SeriesId = s.SeriesId,
|
||||||
|
@ -252,8 +265,8 @@ private List<SeriesModel> GetSeriesModels(List<Series> seriesInDb)
|
||||||
SeasonsCount = s.Seasons.Where(x => x.SeasonNumber > 0).Count(),
|
SeasonsCount = s.Seasons.Where(x => x.SeasonNumber > 0).Count(),
|
||||||
SeasonFolder = s.SeasonFolder,
|
SeasonFolder = s.SeasonFolder,
|
||||||
Status = s.Status,
|
Status = s.Status,
|
||||||
Episodes = episodesTotal.Where(e => e.EpisodeFileId != 0).Count(),
|
Episodes = 0,
|
||||||
EpisodeTotal = episodesTotal.Count()
|
EpisodeTotal = 0
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -151,14 +151,26 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function grid_rowBound(e) {
|
function grid_rowBound(e) {
|
||||||
var data = e.dataItem;
|
var dataItem = e.dataItem;
|
||||||
|
var seriesId = dataItem.SeriesId;
|
||||||
|
var getEpisodeCountUrl = '@Url.Action("GetEpisodeCount", "Series")';
|
||||||
|
|
||||||
var seriesId = data.SeriesId;
|
$("#progressbar_" + seriesId).episodeProgress(0, 0);
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: "GET",
|
||||||
|
url: getEpisodeCountUrl,
|
||||||
|
data: jQuery.param({ seriesId: seriesId }),
|
||||||
|
error: function (req, status, error) {
|
||||||
|
alert("Sorry! We could search for " + id + " at this time. " + error);
|
||||||
|
},
|
||||||
|
success: function (data, textStatus, jqXHR) {
|
||||||
var episodes = data.Episodes;
|
var episodes = data.Episodes;
|
||||||
var episodeTotal = data.EpisodeTotal;
|
var episodeTotal = data.EpisodeTotal;
|
||||||
|
|
||||||
$("#progressbar_" + seriesId).episodeProgress(episodes, episodeTotal);
|
$("#progressbar_" + seriesId).episodeProgress(episodes, episodeTotal);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function openSeasonEditor(seriesId, seriesName) {
|
function openSeasonEditor(seriesId, seriesName) {
|
||||||
|
|
Loading…
Reference in a new issue