mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-04-24 14:08:44 -04:00
Add PaginatedQuery abstract class, change startIndex to skip
This commit is contained in:
parent
e1f7086077
commit
ab63a7745c
4 changed files with 21 additions and 13 deletions
|
@ -47,7 +47,7 @@ namespace Jellyfin.Api.Controllers
|
|||
{
|
||||
return await _activityManager.GetPagedResultAsync(new ActivityLogQuery
|
||||
{
|
||||
StartIndex = startIndex,
|
||||
Skip = startIndex,
|
||||
Limit = limit,
|
||||
MinDate = minDate,
|
||||
HasUserId = hasUserId
|
||||
|
|
|
@ -5,18 +5,8 @@ namespace Jellyfin.Data.Queries
|
|||
/// <summary>
|
||||
/// A class representing a query to the activity logs.
|
||||
/// </summary>
|
||||
public class ActivityLogQuery
|
||||
public class ActivityLogQuery : PaginatedQuery
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the index to start at.
|
||||
/// </summary>
|
||||
public int? StartIndex { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum number of items to include.
|
||||
/// </summary>
|
||||
public int? Limit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether to take entries with a user id.
|
||||
/// </summary>
|
||||
|
|
18
Jellyfin.Data/Queries/PaginatedQuery.cs
Normal file
18
Jellyfin.Data/Queries/PaginatedQuery.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
namespace Jellyfin.Data.Queries
|
||||
{
|
||||
/// <summary>
|
||||
/// An abstract class for paginated queries.
|
||||
/// </summary>
|
||||
public abstract class PaginatedQuery
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the index to start at.
|
||||
/// </summary>
|
||||
public int? Skip { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum number of items to include.
|
||||
/// </summary>
|
||||
public int? Limit { get; set; }
|
||||
}
|
||||
}
|
|
@ -62,7 +62,7 @@ namespace Jellyfin.Server.Implementations.Activity
|
|||
return new QueryResult<ActivityLogEntry>
|
||||
{
|
||||
Items = await entries
|
||||
.Skip(query.StartIndex ?? 0)
|
||||
.Skip(query.Skip ?? 0)
|
||||
.Take(query.Limit ?? 100)
|
||||
.AsAsyncEnumerable()
|
||||
.Select(ConvertToOldModel)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue