fix: restore Include(p => p.Albums) in PersonRepository queries

The visibility subquery doesn't load the Albums navigation, so TotalAlbums in the mapper was always 0. Added back a lightweight Include(p => p.Albums) (without Assets/SharedWith chain) to both SearchQuery and GetAllVisible.
This commit is contained in:
REDCODE
2026-07-11 20:39:14 +02:00
parent 837491fa4a
commit 41c262d157

View File

@@ -31,6 +31,7 @@ public class PersonRepository(LactoseDbContext context) : IPersonRepository {
return GetAll();
return context.People
.Include(p => p.Albums)
.Where(p => p.Albums!.Any(a =>
a.Assets!.Any(asset => asset.DeletedAt == null && (
asset.IsPubliclyShared ||
@@ -58,7 +59,7 @@ public class PersonRepository(LactoseDbContext context) : IPersonRepository {
/// <inheritdoc />
public IEnumerable<Person> SearchQuery(string query, int page = 0, int pageSize = 30, string? sortBy = null, bool sortAsc = true, Guid userId = default, EAccessLevel accessLevel = EAccessLevel.User) {
IQueryable<Person> peopleQuery = context.People;
IQueryable<Person> peopleQuery = context.People.Include(p => p.Albums);
if (!string.IsNullOrEmpty(query))
peopleQuery = peopleQuery.Where(p => EF.Functions.ILike(p.Name, $"%{query}%"));