Merge pull request #4326 from crobibero/purge-activity-log

Automatically clean activity log database
This commit is contained in:
Bond-009
2020-11-02 16:52:49 +01:00
committed by GitHub
5 changed files with 105 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