Automatically clean activity log database

This commit is contained in:
crobibero
2020-10-14 11:44:11 -06:00
parent d54de29485
commit 15a7f88e08
4 changed files with 89 additions and 0 deletions

View File

@@ -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