Skip to content

Commit

Permalink
Bulk Audit fixes (#113)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrii Kaplanovskyi <[email protected]>
  • Loading branch information
andriikaplanovskyi and andrii-kaplanovskyi authored Oct 27, 2023
1 parent 0e6d84f commit dbfcb7d
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using EnsureThat;
Expand Down Expand Up @@ -47,7 +48,10 @@ public async Task WriteAsync<TEntity>(TEntity entity, AuditEvent auditEntityEven

public async Task FlushAsync(CancellationToken cancellationToken)
{
await _repository.AddBulkAsync(_auditEvents, cancellationToken);
_auditEvents.Clear();
if (_auditEvents.Any())
{
await _repository.AddBulkAsync(_auditEvents, cancellationToken);
_auditEvents.Clear();
}
}
}

0 comments on commit dbfcb7d

Please sign in to comment.