The Free Software Media System - Server Backend & API
add NameStartsWith and NameLessThan filters to Person search
dkanada22644075e784
diff --git a/Jellyfin.Api/Controllers/PersonsController.cs b/Jellyfin.Api/Controllers/PersonsController.csindex 2b2afb0fe6..a113ded049 100644--- a/Jellyfin.Api/Controllers/PersonsController.cs+++ b/Jellyfin.Api/Controllers/PersonsController.cs@@ -50,6 +50,8 @@ public class PersonsController : BaseJellyfinApiController/// <param name="startIndex">Optional. All items with a lower index will be dropped from the response.</param>/// <param name="limit">Optional. The maximum number of records to return.</param>/// <param name="searchTerm">The search term.</param>+ /// <param name="nameStartsWith">Optional. Filter by items whose name starts with the given input string.</param>+ /// <param name="nameLessThan">Optional. Filter by items whose name will appear before this value when sorted alphabetically.</param>/// <param name="fields">Optional. Specify additional fields of information to return in the output.</param>/// <param name="filters">Optional. Specify additional filters to apply.</param>/// <param name="isFavorite">Optional filter by items that are marked as favorite, or not. userId is required.</param>@@ -70,6 +72,8 @@ public class PersonsController : BaseJellyfinApiController[FromQuery] int? startIndex,[FromQuery] int? limit,[FromQuery] string? searchTerm,+ [FromQuery] string? nameStartsWith,+ [FromQuery] string? nameLessThan,[FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFields[] fields,[FromQuery, ModelBinder(typeof(CommaDelimitedCollectionModelBinder))] ItemFilter[] filters,[FromQuery] bool? isFavorite,@@ -97,6 +101,8 @@ public class PersonsController : BaseJellyfinApiControllerexcludePersonTypes){NameContains = searchTerm,+ NameStartsWith = nameStartsWith,+ NameLessThan = nameLessThan,User = user,IsFavorite = !isFavorite.HasValue && isFavoriteInFilters ? true : isFavorite,AppearsInItemId = appearsInItemId ?? Guid.Empty,diff --git a/Jellyfin.Server.Implementations/Item/PeopleRepository.cs b/Jellyfin.Server.Implementations/Item/PeopleRepository.csindex ad9953d1b6..adb5e08cf9 100644--- a/Jellyfin.Server.Implementations/Item/PeopleRepository.cs+++ b/Jellyfin.Server.Implementations/Item/PeopleRepository.cs@@ -235,6 +235,16 @@ public class PeopleRepository(IDbContextFactory<JellyfinDbContext> dbProvider, Iquery = query.Where(e => e.Name.ToUpper().Contains(nameContainsUpper));}+ if (!string.IsNullOrWhiteSpace(filter.NameStartsWith))+ {+ query = query.Where(e => e.Name.StartsWith(filter.NameStartsWith.ToLowerInvariant()));+ }++ if (!string.IsNullOrWhiteSpace(filter.NameLessThan))+ {+ query = query.Where(e => e.Name.CompareTo(filter.NameLessThan.ToLowerInvariant()) < 0);+ }+return query;}diff --git a/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs b/MediaBrowser.Controller/Entities/InternalPeopleQuery.csindex f4b3910b0e..373ec7ffeb 100644--- a/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs+++ b/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs@@ -42,6 +42,10 @@ namespace MediaBrowser.Controller.Entitiespublic string NameContains { get; set; }+ public string NameStartsWith { get; set; }++ public string NameLessThan { get; set; }+public User User { get; set; }public bool? IsFavorite { get; set; }