diff options
Diffstat (limited to 'Jellyfin.Server.Implementations/Activity/ActivityManager.cs')
| -rw-r--r-- | Jellyfin.Server.Implementations/Activity/ActivityManager.cs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/Jellyfin.Server.Implementations/Activity/ActivityManager.cs b/Jellyfin.Server.Implementations/Activity/ActivityManager.cs index d7bbf793c..65ceee32b 100644 --- a/Jellyfin.Server.Implementations/Activity/ActivityManager.cs +++ b/Jellyfin.Server.Implementations/Activity/ActivityManager.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Jellyfin.Data.Entities; @@ -14,7 +13,7 @@ namespace Jellyfin.Server.Implementations.Activity /// </summary> public class ActivityManager : IActivityManager { - private JellyfinDbProvider _provider; + private readonly JellyfinDbProvider _provider; /// <summary> /// Initializes a new instance of the <see cref="ActivityManager"/> class. @@ -50,31 +49,31 @@ namespace Jellyfin.Server.Implementations.Activity /// <inheritdoc/> public QueryResult<ActivityLogEntry> GetPagedResult( - Func<IQueryable<ActivityLog>, IEnumerable<ActivityLog>> func, + Func<IQueryable<ActivityLog>, IQueryable<ActivityLog>> func, int? startIndex, int? limit) { using var dbContext = _provider.CreateContext(); - var result = func.Invoke(dbContext.ActivityLogs).AsQueryable(); + var query = func(dbContext.ActivityLogs.OrderByDescending(entry => entry.DateCreated)); if (startIndex.HasValue) { - result = result.Where(entry => entry.Id >= startIndex.Value); + query = query.Skip(startIndex.Value); } if (limit.HasValue) { - result = result.OrderByDescending(entry => entry.DateCreated).Take(limit.Value); + query = query.Take(limit.Value); } // This converts the objects from the new database model to the old for compatibility with the existing API. - var list = result.Select(entry => ConvertToOldModel(entry)).ToList(); + var list = query.Select(ConvertToOldModel).ToList(); - return new QueryResult<ActivityLogEntry>() + return new QueryResult<ActivityLogEntry> { Items = list, - TotalRecordCount = list.Count + TotalRecordCount = func(dbContext.ActivityLogs).Count() }; } |
