mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 10:47:08 -07:00
Fixed: History grid loads faster (lazy loaded)
This commit is contained in:
parent
69a19b14c8
commit
d44c07b27b
23 changed files with 245 additions and 39 deletions
|
@ -1,6 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using DataTables.Mvc.Core.Helpers;
|
||||
using DataTables.Mvc.Core.Models;
|
||||
using Ninject;
|
||||
using NLog;
|
||||
using NzbDrone.Core.Model;
|
||||
|
@ -77,5 +79,42 @@ namespace NzbDrone.Core.Providers
|
|||
{
|
||||
_database.Delete<History>(historyId);
|
||||
}
|
||||
|
||||
public virtual Page<HistoryQueryModel> GetPagedItems(DataTablesPageRequest pageRequest)
|
||||
{
|
||||
var query = Sql.Builder
|
||||
.Select(@"History.*, Series.Title as SeriesTitle, Episodes.Title as EpisodeTitle,
|
||||
Episodes.SeasonNumber as SeasonNumber, Episodes.EpisodeNumber as EpisodeNumber,
|
||||
Episodes.Overview as EpisodeOverview")
|
||||
.From("History")
|
||||
.InnerJoin("Series")
|
||||
.On("History.SeriesId = Series.SeriesId")
|
||||
.InnerJoin("Episodes")
|
||||
.On("History.EpisodeId = Episodes.EpisodeId");
|
||||
|
||||
var startPage = (pageRequest.DisplayLength == 0) ? 1 : pageRequest.DisplayStart / pageRequest.DisplayLength + 1;
|
||||
|
||||
if (!string.IsNullOrEmpty(pageRequest.Search))
|
||||
{
|
||||
var whereClause = string.Join(" OR ", SqlBuilderHelper.GetSearchClause(pageRequest));
|
||||
|
||||
if (!string.IsNullOrEmpty(whereClause))
|
||||
query.Append("WHERE " + whereClause, "%" + pageRequest.Search + "%");
|
||||
}
|
||||
|
||||
var orderBy = string.Join(",", SqlBuilderHelper.GetOrderByClause(pageRequest));
|
||||
|
||||
if (!string.IsNullOrEmpty(orderBy))
|
||||
{
|
||||
query.Append("ORDER BY " + orderBy);
|
||||
}
|
||||
|
||||
return _database.Page<HistoryQueryModel>(startPage, pageRequest.DisplayLength, query);
|
||||
}
|
||||
|
||||
public virtual long Count()
|
||||
{
|
||||
return _database.Single<long>(@"SELECT COUNT(*) from History");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue