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,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 @@ namespace NzbDrone.Web.Controllers
|
||||||
[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>();
|
||||||
SeriesId = e.Series.SeriesId,
|
|
||||||
EpisodeId = e.EpisodeId,
|
foreach (var item in upcomingDb)
|
||||||
SeriesName = e.Series.Title,
|
{
|
||||||
SeasonNumber = e.SeasonNumber,
|
var series = item.Series;
|
||||||
EpisodeNumber = e.EpisodeNumber,
|
|
||||||
Title = e.Title,
|
upcoming.Add(new UpcomingEpisodeModel
|
||||||
Overview = e.Overview,
|
{
|
||||||
AirDate = e.AirDate.Add(Convert.ToDateTime(e.Series.AirTimes).TimeOfDay)
|
SeriesId = series.SeriesId,
|
||||||
});
|
EpisodeId = item.EpisodeId,
|
||||||
|
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));
|
||||||
}
|
}
|
||||||
|
@ -45,16 +54,25 @@ namespace NzbDrone.Web.Controllers
|
||||||
[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>();
|
||||||
SeriesId = e.Series.SeriesId,
|
|
||||||
SeriesName = e.Series.Title,
|
foreach (var item in upcomingDb)
|
||||||
SeasonNumber = e.SeasonNumber,
|
{
|
||||||
EpisodeNumber = e.EpisodeNumber,
|
var series = item.Series;
|
||||||
Title = e.Title,
|
|
||||||
Overview = e.Overview,
|
upcoming.Add(new UpcomingEpisodeModel
|
||||||
AirDate = e.AirDate.Add(Convert.ToDateTime(e.Series.AirTimes).TimeOfDay)
|
{
|
||||||
});
|
SeriesId = series.SeriesId,
|
||||||
|
EpisodeId = item.EpisodeId,
|
||||||
|
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 @@ namespace NzbDrone.Web.Controllers
|
||||||
[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 @@ namespace NzbDrone.Web.Controllers
|
||||||
[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>();
|
||||||
SeriesId = e.Series.SeriesId,
|
|
||||||
SeriesName = e.Series.Title,
|
foreach (var item in upcomingDb)
|
||||||
SeasonNumber = e.SeasonNumber,
|
{
|
||||||
EpisodeNumber = e.EpisodeNumber,
|
var series = item.Series;
|
||||||
Title = e.Title,
|
|
||||||
Overview = e.Overview,
|
upcoming.Add(new UpcomingEpisodeModel
|
||||||
AirDate = e.AirDate.Add(Convert.ToDateTime(e.Series.AirTimes).TimeOfDay)
|
{
|
||||||
});
|
SeriesId = series.SeriesId,
|
||||||
|
EpisodeId = item.EpisodeId,
|
||||||
|
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 New Issue