@ -121,23 +121,21 @@ namespace NzbDrone.Core.History
public PagingSpec < EntityHistory > GetPaged ( PagingSpec < EntityHistory > pagingSpec , int [ ] qualities )
{
pagingSpec . Records = GetPagedRecords ( PagedBuilder ( pagingSpec, qualities) , pagingSpec , PagedQuery ) ;
pagingSpec . Records = GetPagedRecords ( PagedBuilder ( qualities) , pagingSpec , PagedQuery ) ;
var countTemplate = $"SELECT COUNT(*) FROM (SELECT /**select**/ FROM \" { TableMapping . Mapper . TableNameMapping ( typeof ( EntityHistory ) ) } \ " /**join**/ /**innerjoin**/ /**leftjoin**/ /**where**/ /**groupby**/ /**having**/) AS \"Inner\"" ;
pagingSpec . TotalRecords = GetPagedRecordCount ( PagedBuilder ( pagingSpec, qualities) . Select ( typeof ( EntityHistory ) ) , pagingSpec , countTemplate ) ;
pagingSpec . TotalRecords = GetPagedRecordCount ( PagedBuilder ( qualities) . Select ( typeof ( EntityHistory ) ) , pagingSpec , countTemplate ) ;
return pagingSpec ;
}
private SqlBuilder PagedBuilder ( PagingSpec < EntityHistory > pagingSpec , int [ ] qualities )
private SqlBuilder PagedBuilder ( int [ ] qualities )
{
var builder = Builder ( )
. Join < EntityHistory , Artist > ( ( h , a ) = > h . ArtistId = = a . Id )
. Join < EntityHistory , Album > ( ( h , a ) = > h . AlbumId = = a . Id )
. LeftJoin < EntityHistory , Track > ( ( h , t ) = > h . TrackId = = t . Id ) ;
AddFilters ( builder , pagingSpec ) ;
if ( qualities is { Length : > 0 } )
{
builder . Where ( $"({BuildQualityWhereClause(qualities)})" ) ;