aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Server.Implementations/Activity
diff options
context:
space:
mode:
authorPatrick Barron <barronpm@gmail.com>2020-05-14 17:13:45 -0400
committerPatrick Barron <barronpm@gmail.com>2020-05-14 17:13:45 -0400
commitb94afc597c4d51f67552c9ba2c25bdb8df6d8599 (patch)
tree797ec581adbde8cf12e68d514fb2db631dcee599 /Jellyfin.Server.Implementations/Activity
parent992574291821ba417ac624aeb0bf0022159b5c30 (diff)
Address review comments
Diffstat (limited to 'Jellyfin.Server.Implementations/Activity')
-rw-r--r--Jellyfin.Server.Implementations/Activity/ActivityManager.cs14
1 files changed, 7 insertions, 7 deletions
diff --git a/Jellyfin.Server.Implementations/Activity/ActivityManager.cs b/Jellyfin.Server.Implementations/Activity/ActivityManager.cs
index 531b529dc..0b398b60c 100644
--- a/Jellyfin.Server.Implementations/Activity/ActivityManager.cs
+++ b/Jellyfin.Server.Implementations/Activity/ActivityManager.cs
@@ -50,31 +50,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).AsQueryable();
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.AsEnumerable().Select(ConvertToOldModel).ToList();
- return new QueryResult<ActivityLogEntry>()
+ return new QueryResult<ActivityLogEntry>
{
Items = list,
- TotalRecordCount = list.Count
+ TotalRecordCount = dbContext.ActivityLogs.Count()
};
}