aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Server.Implementations/Activity/ActivityManager.cs
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2020-11-02 16:52:49 +0100
committerGitHub <noreply@github.com>2020-11-02 16:52:49 +0100
commit51dc92c3a91a2dfc9109b4e734b34e7c7374b038 (patch)
tree3d1f18d57e4ef30916ff740a9adcfd3c38e95e9f /Jellyfin.Server.Implementations/Activity/ActivityManager.cs
parent95918d161ed72cb2914cb3f3b7f55de46ed86372 (diff)
parentde36c8433e6b64e15ffb8535c0e6d1ccb264c49e (diff)
Merge pull request #4326 from crobibero/purge-activity-log
Automatically clean activity log database
Diffstat (limited to 'Jellyfin.Server.Implementations/Activity/ActivityManager.cs')
-rw-r--r--Jellyfin.Server.Implementations/Activity/ActivityManager.cs12
1 files changed, 12 insertions, 0 deletions
diff --git a/Jellyfin.Server.Implementations/Activity/ActivityManager.cs b/Jellyfin.Server.Implementations/Activity/ActivityManager.cs
index 5926abfe0..7bde4f35b 100644
--- a/Jellyfin.Server.Implementations/Activity/ActivityManager.cs
+++ b/Jellyfin.Server.Implementations/Activity/ActivityManager.cs
@@ -72,6 +72,18 @@ namespace Jellyfin.Server.Implementations.Activity
};
}
+ /// <inheritdoc />
+ public async Task CleanAsync(DateTime startDate)
+ {
+ await using var dbContext = _provider.CreateContext();
+ var entries = dbContext.ActivityLogs
+ .AsQueryable()
+ .Where(entry => entry.DateCreated <= startDate);
+
+ dbContext.RemoveRange(entries);
+ await dbContext.SaveChangesAsync().ConfigureAwait(false);
+ }
+
private static ActivityLogEntry ConvertToOldModel(ActivityLog entry)
{
return new ActivityLogEntry