mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-17 06:23:03 +03:00
Automatically clean activity log database
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user