HistoryProvider will return History Items with Episode and SeriesTitle.

This commit is contained in:
Mark McDowall 2011-06-19 16:44:45 -07:00
parent 5c055ebb9a
commit 0972c956b8
3 changed files with 29 additions and 24 deletions

View File

@ -25,9 +25,18 @@ namespace NzbDrone.Core.Providers
{
}
public virtual IEnumerable<History> AllItems()
public virtual List<History> AllItems()
{
return _database.Query<History>("");
return _database.Fetch<History>("");
}
public virtual List<History> AllItemsWithRelationships()
{
return _database.Fetch<History, Episode>(@"
SELECT History.*, Series.Title as SeriesTitle, Episodes.* FROM History
INNER JOIN Series ON History.SeriesId = Series.SeriesId
INNER JOIN Episodes ON History.EpisodeId = Episodes.EpisodeId
");
}
public virtual void Purge()

View File

@ -16,5 +16,11 @@ namespace NzbDrone.Core.Repository
public DateTime Date { get; set; }
public bool IsProper { get; set; }
public string Indexer { get; set; }
[ResultColumn]
public Episode Episode { get; set; }
[ResultColumn]
public string SeriesTitle { get; set; }
}
}

View File

@ -46,30 +46,20 @@ namespace NzbDrone.Web.Controllers
[GridAction]
public ActionResult _AjaxBinding()
{
var historyDb = _historyProvider.AllItems();
var history = new List<HistoryModel>();
foreach (var item in historyDb)
{
var episode = _episodeProvider.GetEpisode(item.EpisodeId);
var series = _seriesProvider.GetSeries(item.SeriesId);
history.Add(new HistoryModel
var history = _historyProvider.AllItemsWithRelationships().Select(h => new HistoryModel
{
HistoryId = item.HistoryId,
SeasonNumber = episode.SeasonNumber,
EpisodeNumber = episode.EpisodeNumber,
EpisodeTitle = episode.Title,
EpisodeOverview = episode.Overview,
SeriesTitle = series.Title,
NzbTitle = item.NzbTitle,
Quality = item.Quality.ToString(),
IsProper = item.IsProper,
Date = item.Date,
Indexer = item.Indexer
HistoryId = h.HistoryId,
SeasonNumber = h.Episode.SeasonNumber,
EpisodeNumber = h.Episode.EpisodeNumber,
EpisodeTitle = h.Episode.Title,
EpisodeOverview = h.Episode.Overview,
SeriesTitle = h.SeriesTitle,
NzbTitle = h.NzbTitle,
Quality = h.Quality.ToString(),
IsProper = h.IsProper,
Date = h.Date,
Indexer = h.Indexer
});
}
return View(new GridModel(history));
}