UpcomingProvider now gets Series in call for episodes.

This commit is contained in:
Mark McDowall 2011-06-19 20:08:09 -07:00
parent b084a3bc46
commit 86ab26e2d9
3 changed files with 57 additions and 79 deletions

View File

@ -20,8 +20,10 @@ namespace NzbDrone.Core.Providers
public virtual UpcomingEpisodesModel Upcoming()
{
var allEps = _database.Fetch<Episode>("WHERE AirDate BETWEEN @0 AND @1", DateTime.Today.AddDays(-1),
DateTime.Today.AddDays(8));
var allEps = _database.Fetch<Episode, Series>(@"SELECT * FROM Episodes
INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId
WHERE AirDate BETWEEN @0 AND @1",
DateTime.Today.AddDays(-1), DateTime.Today.AddDays(8));
var yesterday = allEps.Where(e => e.AirDate == DateTime.Today.AddDays(-1)).ToList();
var today = allEps.Where(e => e.AirDate == DateTime.Today).ToList();
@ -32,22 +34,30 @@ namespace NzbDrone.Core.Providers
public virtual List<Episode> Yesterday()
{
return _database.Fetch<Episode>("WHERE AirDate = @0", DateTime.Today.AddDays(-1));
return _database.Fetch<Episode, Series>(@"SELECT * FROM Episodes
INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId
WHERE AirDate = @0", DateTime.Today.AddDays(-1));
}
public virtual List<Episode> Today()
{
return _database.Fetch<Episode>("WHERE AirDate = @0", DateTime.Today);
return _database.Fetch<Episode, Series>(@"SELECT * FROM Episodes
INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId
WHERE AirDate = @0", DateTime.Today);
}
public virtual List<Episode> Tomorrow()
{
return _database.Fetch<Episode>("WHERE AirDate = @0", DateTime.Today.AddDays(1));
return _database.Fetch<Episode, Series>(@"SELECT * FROM Episodes
INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId
WHERE AirDate = @0", DateTime.Today.AddDays(1));
}
public virtual List<Episode> Week()
{
return _database.Fetch<Episode>("WHERE AirDate BETWEEN @0 AND @1", DateTime.Today.AddDays(2), DateTime.Today.AddDays(8));
return _database.Fetch<Episode, Series>(@"SELECT * FROM Episodes
INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId
WHERE AirDate BETWEEN @0 AND @1", DateTime.Today.AddDays(2), DateTime.Today.AddDays(8));
}
}
}

View File

@ -32,7 +32,7 @@ namespace NzbDrone.Core.Repository
/// </remarks>
public DateTime? GrabDate { get; set; }
[Ignore]
[ResultColumn]
public EpisodeStatusType Status
{
get

View File

@ -30,25 +30,17 @@ namespace NzbDrone.Web.Controllers
[GridAction]
public ActionResult _AjaxBindingYesterday()
{
var upcomingDb = _upcomingEpisodesProvider.Yesterday();
var upcoming = new List<UpcomingEpisodeModel>();
foreach (var item in upcomingDb)
var upcoming = _upcomingEpisodesProvider.Yesterday().Select(u => new UpcomingEpisodeModel
{
var series = _seriesProvider.GetSeries(item.SeriesId);
upcoming.Add(new UpcomingEpisodeModel
{
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)
});
}
SeriesId = u.Series.SeriesId,
EpisodeId = u.EpisodeId,
SeriesName = u.Series.Title,
SeasonNumber = u.SeasonNumber,
EpisodeNumber = u.EpisodeNumber,
Title = u.Title,
Overview = u.Overview,
AirDate = u.AirDate.Add(Convert.ToDateTime(u.Series.AirTimes).TimeOfDay)
});
return View(new GridModel(upcoming));
}
@ -56,25 +48,17 @@ namespace NzbDrone.Web.Controllers
[GridAction]
public ActionResult _AjaxBindingToday()
{
var upcomingDb = _upcomingEpisodesProvider.Today();
var upcoming = new List<UpcomingEpisodeModel>();
foreach (var item in upcomingDb)
var upcoming = _upcomingEpisodesProvider.Today().Select(u => new UpcomingEpisodeModel
{
var series = _seriesProvider.GetSeries(item.SeriesId);
upcoming.Add(new UpcomingEpisodeModel
{
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)
});
}
SeriesId = u.Series.SeriesId,
EpisodeId = u.EpisodeId,
SeriesName = u.Series.Title,
SeasonNumber = u.SeasonNumber,
EpisodeNumber = u.EpisodeNumber,
Title = u.Title,
Overview = u.Overview,
AirDate = u.AirDate.Add(Convert.ToDateTime(u.Series.AirTimes).TimeOfDay)
});
return View(new GridModel(upcoming));
}
@ -82,25 +66,17 @@ namespace NzbDrone.Web.Controllers
[GridAction]
public ActionResult _AjaxBindingTomorrow()
{
var upcomingDb = _upcomingEpisodesProvider.Tomorrow();
var upcoming = new List<UpcomingEpisodeModel>();
foreach (var item in upcomingDb)
var upcoming = _upcomingEpisodesProvider.Tomorrow().Select(u => new UpcomingEpisodeModel
{
var series = _seriesProvider.GetSeries(item.SeriesId);
upcoming.Add(new UpcomingEpisodeModel
{
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)
});
}
SeriesId = u.Series.SeriesId,
EpisodeId = u.EpisodeId,
SeriesName = u.Series.Title,
SeasonNumber = u.SeasonNumber,
EpisodeNumber = u.EpisodeNumber,
Title = u.Title,
Overview = u.Overview,
AirDate = u.AirDate.Add(Convert.ToDateTime(u.Series.AirTimes).TimeOfDay)
});
return View(new GridModel(upcoming));
}
@ -108,25 +84,17 @@ namespace NzbDrone.Web.Controllers
[GridAction]
public ActionResult _AjaxBindingWeek()
{
var upcomingDb = _upcomingEpisodesProvider.Week();
var upcoming = new List<UpcomingEpisodeModel>();
foreach (var item in upcomingDb)
var upcoming = _upcomingEpisodesProvider.Week().Select(u => new UpcomingEpisodeModel
{
var series = _seriesProvider.GetSeries(item.SeriesId);
upcoming.Add(new UpcomingEpisodeModel
{
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)
});
}
SeriesId = u.Series.SeriesId,
EpisodeId = u.EpisodeId,
SeriesName = u.Series.Title,
SeasonNumber = u.SeasonNumber,
EpisodeNumber = u.EpisodeNumber,
Title = u.Title,
Overview = u.Overview,
AirDate = u.AirDate.Add(Convert.ToDateTime(u.Series.AirTimes).TimeOfDay)
});
return View(new GridModel(upcoming));
}