From f5914da2f94daca890e87cf113df89274927e797 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Fri, 12 Jan 2024 18:54:50 +0200 Subject: [PATCH] Remove double filtering in entity history repository --- src/NzbDrone.Core/History/HistoryRepository.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/NzbDrone.Core/History/HistoryRepository.cs b/src/NzbDrone.Core/History/HistoryRepository.cs index 6f5fd24ec..84a67f3b0 100644 --- a/src/NzbDrone.Core/History/HistoryRepository.cs +++ b/src/NzbDrone.Core/History/HistoryRepository.cs @@ -97,23 +97,21 @@ public List Since(DateTime date, MovieHistoryEventType? eventType) public PagingSpec GetPaged(PagingSpec pagingSpec, int[] languages, int[] qualities) { - pagingSpec.Records = GetPagedRecords(PagedBuilder(pagingSpec, languages, qualities), pagingSpec, PagedQuery); + pagingSpec.Records = GetPagedRecords(PagedBuilder(languages, qualities), pagingSpec, PagedQuery); var countTemplate = $"SELECT COUNT(*) FROM (SELECT /**select**/ FROM \"{TableMapping.Mapper.TableNameMapping(typeof(MovieHistory))}\" /**join**/ /**innerjoin**/ /**leftjoin**/ /**where**/ /**groupby**/ /**having**/) AS \"Inner\""; - pagingSpec.TotalRecords = GetPagedRecordCount(PagedBuilder(pagingSpec, languages, qualities).Select(typeof(MovieHistory)), pagingSpec, countTemplate); + pagingSpec.TotalRecords = GetPagedRecordCount(PagedBuilder(languages, qualities).Select(typeof(MovieHistory)), pagingSpec, countTemplate); return pagingSpec; } - private SqlBuilder PagedBuilder(PagingSpec pagingSpec, int[] languages, int[] qualities) + private SqlBuilder PagedBuilder(int[] languages, int[] qualities) { var builder = Builder() .Join((h, m) => h.MovieId == m.Id) .Join((m, p) => m.QualityProfileId == p.Id) .LeftJoin((m, mm) => m.MovieMetadataId == mm.Id); - AddFilters(builder, pagingSpec); - if (languages is { Length: > 0 }) { builder.Where($"({BuildLanguageWhereClause(languages)})");