Improve performance on people query (#14963)
Some checks failed
CodeQL / Analyze (csharp) (push) Has been cancelled
OpenAPI / OpenAPI - HEAD (push) Has been cancelled
OpenAPI / OpenAPI - BASE (push) Has been cancelled
OpenAPI / OpenAPI - Difference (push) Has been cancelled
OpenAPI / OpenAPI - Publish Unstable Spec (push) Has been cancelled
OpenAPI / OpenAPI - Publish Stable Spec (push) Has been cancelled
Tests / run-tests (macos-latest) (push) Has been cancelled
Tests / run-tests (ubuntu-latest) (push) Has been cancelled
Tests / run-tests (windows-latest) (push) Has been cancelled
Project Automation / Project board (push) Has been cancelled
Merge Conflict Labeler / Labeling (push) Has been cancelled
Stale PR Check / Check PRs with merge conflicts (push) Has been cancelled

This commit is contained in:
theguymadmax
2025-10-08 11:23:20 -04:00
committed by GitHub
parent 79ff0b0b00
commit 07d31c6ba5

View File

@@ -1875,10 +1875,17 @@ public sealed class BaseItemRepository
if (filter.PersonIds.Length > 0)
{
var peopleEntityIds = context.BaseItems
.WhereOneOrMany(filter.PersonIds, b => b.Id)
.Join(
context.Peoples,
b => b.Name,
p => p.Name,
(b, p) => p.Id);
baseQuery = baseQuery
.Where(e =>
context.PeopleBaseItemMap.Where(w => context.BaseItems.Where(r => filter.PersonIds.Contains(r.Id)).Any(f => f.Name == w.People.Name))
.Any(f => f.ItemId == e.Id));
.Where(e => context.PeopleBaseItemMap
.Any(m => m.ItemId == e.Id && peopleEntityIds.Contains(m.PeopleId)));
}
if (!string.IsNullOrWhiteSpace(filter.Person))