mirror of
https://github.com/lidarr/Lidarr
synced 2024-12-27 10:07:10 +00:00
Upcoming view will no longer hit the DB with the same request so many times.
This commit is contained in:
parent
3572855c34
commit
c8ae3de292
1 changed files with 76 additions and 40 deletions
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
|
@ -27,17 +28,25 @@ public ActionResult Index()
|
||||||
[GridAction]
|
[GridAction]
|
||||||
public ActionResult _AjaxBindingYesterday()
|
public ActionResult _AjaxBindingYesterday()
|
||||||
{
|
{
|
||||||
var upcoming = _upcomingEpisodesProvider.Yesterday().Select(e => new UpcomingEpisodeModel
|
var upcomingDb = _upcomingEpisodesProvider.Yesterday();
|
||||||
|
var upcoming = new List<UpcomingEpisodeModel>();
|
||||||
|
|
||||||
|
foreach (var item in upcomingDb)
|
||||||
{
|
{
|
||||||
SeriesId = e.Series.SeriesId,
|
var series = item.Series;
|
||||||
EpisodeId = e.EpisodeId,
|
|
||||||
SeriesName = e.Series.Title,
|
upcoming.Add(new UpcomingEpisodeModel
|
||||||
SeasonNumber = e.SeasonNumber,
|
{
|
||||||
EpisodeNumber = e.EpisodeNumber,
|
SeriesId = series.SeriesId,
|
||||||
Title = e.Title,
|
EpisodeId = item.EpisodeId,
|
||||||
Overview = e.Overview,
|
SeriesName = series.Title,
|
||||||
AirDate = e.AirDate.Add(Convert.ToDateTime(e.Series.AirTimes).TimeOfDay)
|
SeasonNumber = item.SeasonNumber,
|
||||||
|
EpisodeNumber = item.EpisodeNumber,
|
||||||
|
Title = item.Title,
|
||||||
|
Overview = item.Overview,
|
||||||
|
AirDate = item.AirDate.Add(Convert.ToDateTime(series.AirTimes).TimeOfDay)
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return View(new GridModel(upcoming));
|
return View(new GridModel(upcoming));
|
||||||
}
|
}
|
||||||
|
@ -45,16 +54,25 @@ public ActionResult _AjaxBindingYesterday()
|
||||||
[GridAction]
|
[GridAction]
|
||||||
public ActionResult _AjaxBindingToday()
|
public ActionResult _AjaxBindingToday()
|
||||||
{
|
{
|
||||||
var upcoming = _upcomingEpisodesProvider.Today().Select(e => new UpcomingEpisodeModel
|
var upcomingDb = _upcomingEpisodesProvider.Today();
|
||||||
|
var upcoming = new List<UpcomingEpisodeModel>();
|
||||||
|
|
||||||
|
foreach (var item in upcomingDb)
|
||||||
{
|
{
|
||||||
SeriesId = e.Series.SeriesId,
|
var series = item.Series;
|
||||||
SeriesName = e.Series.Title,
|
|
||||||
SeasonNumber = e.SeasonNumber,
|
upcoming.Add(new UpcomingEpisodeModel
|
||||||
EpisodeNumber = e.EpisodeNumber,
|
{
|
||||||
Title = e.Title,
|
SeriesId = series.SeriesId,
|
||||||
Overview = e.Overview,
|
EpisodeId = item.EpisodeId,
|
||||||
AirDate = e.AirDate.Add(Convert.ToDateTime(e.Series.AirTimes).TimeOfDay)
|
SeriesName = series.Title,
|
||||||
|
SeasonNumber = item.SeasonNumber,
|
||||||
|
EpisodeNumber = item.EpisodeNumber,
|
||||||
|
Title = item.Title,
|
||||||
|
Overview = item.Overview,
|
||||||
|
AirDate = item.AirDate.Add(Convert.ToDateTime(series.AirTimes).TimeOfDay)
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return View(new GridModel(upcoming));
|
return View(new GridModel(upcoming));
|
||||||
}
|
}
|
||||||
|
@ -62,16 +80,25 @@ public ActionResult _AjaxBindingToday()
|
||||||
[GridAction]
|
[GridAction]
|
||||||
public ActionResult _AjaxBindingTomorrow()
|
public ActionResult _AjaxBindingTomorrow()
|
||||||
{
|
{
|
||||||
var upcoming = _upcomingEpisodesProvider.Tomorrow().Select(e => new UpcomingEpisodeModel
|
var upcomingDb = _upcomingEpisodesProvider.Tomorrow();
|
||||||
|
var upcoming = new List<UpcomingEpisodeModel>();
|
||||||
|
|
||||||
|
foreach (var item in upcomingDb)
|
||||||
{
|
{
|
||||||
SeriesId = e.Series.SeriesId,
|
var series = item.Series;
|
||||||
SeriesName = e.Series.Title,
|
|
||||||
SeasonNumber = e.SeasonNumber,
|
upcoming.Add(new UpcomingEpisodeModel
|
||||||
EpisodeNumber = e.EpisodeNumber,
|
{
|
||||||
Title = e.Title,
|
SeriesId = series.SeriesId,
|
||||||
Overview = e.Overview,
|
EpisodeId = item.EpisodeId,
|
||||||
AirDate = e.AirDate.Add(Convert.ToDateTime(e.Series.AirTimes).TimeOfDay)
|
SeriesName = series.Title,
|
||||||
|
SeasonNumber = item.SeasonNumber,
|
||||||
|
EpisodeNumber = item.EpisodeNumber,
|
||||||
|
Title = item.Title,
|
||||||
|
Overview = item.Overview,
|
||||||
|
AirDate = item.AirDate.Add(Convert.ToDateTime(series.AirTimes).TimeOfDay)
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return View(new GridModel(upcoming));
|
return View(new GridModel(upcoming));
|
||||||
}
|
}
|
||||||
|
@ -79,16 +106,25 @@ public ActionResult _AjaxBindingTomorrow()
|
||||||
[GridAction]
|
[GridAction]
|
||||||
public ActionResult _AjaxBindingWeek()
|
public ActionResult _AjaxBindingWeek()
|
||||||
{
|
{
|
||||||
var upcoming = _upcomingEpisodesProvider.Week().Select(e => new UpcomingEpisodeModel
|
var upcomingDb = _upcomingEpisodesProvider.Week();
|
||||||
|
var upcoming = new List<UpcomingEpisodeModel>();
|
||||||
|
|
||||||
|
foreach (var item in upcomingDb)
|
||||||
{
|
{
|
||||||
SeriesId = e.Series.SeriesId,
|
var series = item.Series;
|
||||||
SeriesName = e.Series.Title,
|
|
||||||
SeasonNumber = e.SeasonNumber,
|
upcoming.Add(new UpcomingEpisodeModel
|
||||||
EpisodeNumber = e.EpisodeNumber,
|
{
|
||||||
Title = e.Title,
|
SeriesId = series.SeriesId,
|
||||||
Overview = e.Overview,
|
EpisodeId = item.EpisodeId,
|
||||||
AirDate = e.AirDate.Add(Convert.ToDateTime(e.Series.AirTimes).TimeOfDay)
|
SeriesName = series.Title,
|
||||||
|
SeasonNumber = item.SeasonNumber,
|
||||||
|
EpisodeNumber = item.EpisodeNumber,
|
||||||
|
Title = item.Title,
|
||||||
|
Overview = item.Overview,
|
||||||
|
AirDate = item.AirDate.Add(Convert.ToDateTime(series.AirTimes).TimeOfDay)
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return View(new GridModel(upcoming));
|
return View(new GridModel(upcoming));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue