aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Server.Implementations/Activity/ActivityManager.cs
diff options
context:
space:
mode:
authorPatrick Barron <barronpm@gmail.com>2020-05-15 17:20:07 -0400
committerPatrick Barron <barronpm@gmail.com>2020-05-15 17:20:07 -0400
commitaca7e221d811040bdb14da6390bbd16c5f7db785 (patch)
tree87c77521066511890e236a97afb27a475f32c0a3 /Jellyfin.Server.Implementations/Activity/ActivityManager.cs
parentb7621d762c58320b35096838ae8ab10d98ea9bb2 (diff)
parent652e9702fc67784fd11e26ee159f31e6f0ba9dd7 (diff)
Merge branch 'master' into userdb-efcore
# Conflicts: # Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs # Emby.Server.Implementations/ApplicationHost.cs # Emby.Server.Implementations/Devices/DeviceManager.cs # Jellyfin.Server/Jellyfin.Server.csproj # Jellyfin.Server/Migrations/MigrationRunner.cs # MediaBrowser.Controller/Devices/IDeviceManager.cs
Diffstat (limited to 'Jellyfin.Server.Implementations/Activity/ActivityManager.cs')
-rw-r--r--Jellyfin.Server.Implementations/Activity/ActivityManager.cs17
1 files changed, 8 insertions, 9 deletions
diff --git a/Jellyfin.Server.Implementations/Activity/ActivityManager.cs b/Jellyfin.Server.Implementations/Activity/ActivityManager.cs
index d7bbf793c4..65ceee32bf 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()
};
}