diff options
| author | Niels van Velzen <nielsvanvelzen@users.noreply.github.com> | 2026-05-04 17:58:27 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-04 17:58:27 +0200 |
| commit | dcba6c36595e7cb74a83e1fca872274e4cabcf93 (patch) | |
| tree | 197b747a07e488d1db81573763c7c6d502195342 /Jellyfin.Server.Implementations | |
| parent | 57821e4cded8cfc4a5fdcca7c15b12d1ecccaaf3 (diff) | |
| parent | ec990be12af3856eea597ba7ebdd5dbfa5b01ace (diff) | |
Merge pull request #16616 from dkanada/fix-person-limit
fix person TotalRecordCount when limit is applied
Diffstat (limited to 'Jellyfin.Server.Implementations')
| -rw-r--r-- | Jellyfin.Server.Implementations/Item/PeopleRepository.cs | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/Jellyfin.Server.Implementations/Item/PeopleRepository.cs b/Jellyfin.Server.Implementations/Item/PeopleRepository.cs index f918d45bcd..cfc4eb2162 100644 --- a/Jellyfin.Server.Implementations/Item/PeopleRepository.cs +++ b/Jellyfin.Server.Implementations/Item/PeopleRepository.cs @@ -1,14 +1,13 @@ using System; using System.Collections.Generic; -using System.Collections.Immutable; using System.Linq; using Jellyfin.Data.Enums; using Jellyfin.Database.Implementations; using Jellyfin.Database.Implementations.Entities; -using Jellyfin.Database.Implementations.Entities.Libraries; using Jellyfin.Extensions; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Persistence; +using MediaBrowser.Model.Querying; using Microsoft.EntityFrameworkCore; namespace Jellyfin.Server.Implementations.Item; @@ -30,7 +29,7 @@ public class PeopleRepository(IDbContextFactory<JellyfinDbContext> dbProvider, I private readonly IDbContextFactory<JellyfinDbContext> _dbProvider = dbProvider; /// <inheritdoc/> - public IReadOnlyList<PersonInfo> GetPeople(InternalPeopleQuery filter) + public QueryResult<PersonInfo> GetPeople(InternalPeopleQuery filter) { using var context = _dbProvider.CreateDbContext(); var dbQuery = TranslateQuery(context.Peoples.AsNoTracking(), context, filter); @@ -48,12 +47,23 @@ public class PeopleRepository(IDbContextFactory<JellyfinDbContext> dbProvider, I dbQuery = dbQuery.OrderBy(e => e.Name); } + var count = dbQuery.Count(); + if (filter.StartIndex.HasValue && filter.StartIndex > 0) + { + dbQuery = dbQuery.Skip(filter.StartIndex.Value); + } + if (filter.Limit > 0) { dbQuery = dbQuery.Take(filter.Limit); } - return dbQuery.AsEnumerable().Select(Map).ToArray(); + return new QueryResult<PersonInfo> + { + StartIndex = filter.StartIndex ?? 0, + TotalRecordCount = count, + Items = dbQuery.AsEnumerable().Select(Map).ToArray(), + }; } /// <inheritdoc/> |
