diff options
| author | Andrew Rabert <6550543+nvllsvm@users.noreply.github.com> | 2019-01-24 23:02:20 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-24 23:02:20 -0500 |
| commit | 48ad18d12baeeb42ec0ec7df9473330dcbc76754 (patch) | |
| tree | d09db721f60f79423f98110e2dc15051787945dc /Emby.Server.Implementations/Activity/ActivityManager.cs | |
| parent | fe197415cac19c0e4005c52761c5e7a37b8a4557 (diff) | |
| parent | 905a253ff5ce2eeee9806b7a4581506468b2fb55 (diff) | |
Merge pull request #452 from Bond-009/activitydb
Use EF Core for Activity database
Diffstat (limited to 'Emby.Server.Implementations/Activity/ActivityManager.cs')
| -rw-r--r-- | Emby.Server.Implementations/Activity/ActivityManager.cs | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/Emby.Server.Implementations/Activity/ActivityManager.cs b/Emby.Server.Implementations/Activity/ActivityManager.cs index 6febcc2f7..8fcacb002 100644 --- a/Emby.Server.Implementations/Activity/ActivityManager.cs +++ b/Emby.Server.Implementations/Activity/ActivityManager.cs @@ -1,9 +1,10 @@ using System; +using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using MediaBrowser.Controller.Library; using MediaBrowser.Model.Activity; using MediaBrowser.Model.Events; -using MediaBrowser.Model.Querying; using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.Activity @@ -26,20 +27,38 @@ namespace Emby.Server.Implementations.Activity _userManager = userManager; } - public void Create(ActivityLogEntry entry) + public async Task CreateAsync(ActivityLogEntry entry) { entry.Date = DateTime.UtcNow; - _repo.Create(entry); + await _repo.CreateAsync(entry); EntryCreated?.Invoke(this, new GenericEventArgs<ActivityLogEntry>(entry)); } - public QueryResult<ActivityLogEntry> GetActivityLogEntries(DateTime? minDate, bool? hasUserId, int? startIndex, int? limit) + public IEnumerable<ActivityLogEntry> GetActivityLogEntries(DateTime? minDate, bool? hasUserId, int? startIndex, int? limit) { - var result = _repo.GetActivityLogEntries(minDate, hasUserId, startIndex, limit); + var result = _repo.GetActivityLogEntries(); - foreach (var item in result.Items.Where(i => !i.UserId.Equals(Guid.Empty))) + if (minDate.HasValue) + { + result = result.Where(x => x.Date >= minDate.Value); + } + if (hasUserId.HasValue) + { + result = result.Where(x => x.UserId != null && x.UserId != Guid.Empty); + } + if (startIndex.HasValue) + { + result = result.Where(x => x.Id >= startIndex.Value); + } + if (limit.HasValue) + { + result = result.Take(limit.Value); + } + + // Add images for each user + foreach (var item in result) { var user = _userManager.GetUserById(item.UserId); @@ -50,12 +69,7 @@ namespace Emby.Server.Implementations.Activity } } - return result; - } - - public QueryResult<ActivityLogEntry> GetActivityLogEntries(DateTime? minDate, int? startIndex, int? limit) - { - return GetActivityLogEntries(minDate, null, startIndex, limit); + return result.AsEnumerable(); } } } |
