mirror of
https://github.com/C9Glax/tranga.git
synced 2025-10-11 05:09:49 +02:00
Use ExecuteDelete instead of ffetching data and then removing the entries
This commit is contained in:
@@ -15,9 +15,8 @@ public class RemoveOldNotificationsWorker(TimeSpan? interval = null, IEnumerable
|
||||
protected override async Task<BaseWorker[]> DoWorkInternal()
|
||||
{
|
||||
Log.Debug("Removing old notifications...");
|
||||
List<Notification> toRemove = await DbContext.Notifications.Where(n => n.IsSent).ToListAsync(CancellationToken);
|
||||
Log.Debug($"Removing {toRemove.Count} old notifications...");
|
||||
DbContext.RemoveRange(toRemove);
|
||||
int removed = await DbContext.Notifications.Where(n => n.IsSent).ExecuteDeleteAsync(CancellationToken);
|
||||
Log.Debug($"Removed {removed} old notifications...");
|
||||
|
||||
if(await DbContext.Sync(CancellationToken, GetType(), System.Reflection.MethodBase.GetCurrentMethod()?.Name) is { success: false } e)
|
||||
Log.Error($"Failed to save database changes: {e.exceptionMessage}");
|
||||
|
Reference in New Issue
Block a user