mirror of
https://github.com/lidarr/Lidarr
synced 2025-01-03 13:34:54 +00:00
Remove double filtering in entity history repository
This commit is contained in:
parent
7b8c17c793
commit
d537d79f75
1 changed files with 3 additions and 5 deletions
|
@ -121,23 +121,21 @@ public List<EntityHistory> Since(DateTime date, EntityHistoryEventType? eventTyp
|
|||
|
||||
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)})");
|
||||
|
|
Loading…
Reference in a new issue