refactor(udt-011): AuditPartitionManagerJob usa TimeProvider inyectado
This commit is contained in:
@@ -19,11 +19,13 @@ public sealed class AuditPartitionManagerJob : IJob
|
||||
|
||||
private readonly SqlConnectionFactory _factory;
|
||||
private readonly ILogger<AuditPartitionManagerJob> _logger;
|
||||
private readonly TimeProvider _timeProvider;
|
||||
|
||||
public AuditPartitionManagerJob(SqlConnectionFactory factory, ILogger<AuditPartitionManagerJob> logger)
|
||||
public AuditPartitionManagerJob(SqlConnectionFactory factory, ILogger<AuditPartitionManagerJob> logger, TimeProvider timeProvider)
|
||||
{
|
||||
_factory = factory;
|
||||
_logger = logger;
|
||||
_timeProvider = timeProvider;
|
||||
}
|
||||
|
||||
public async Task Execute(IJobExecutionContext context)
|
||||
@@ -34,7 +36,7 @@ public sealed class AuditPartitionManagerJob : IJob
|
||||
|
||||
// Target: boundary for "next month + 1" (so the next month is always pre-created and we
|
||||
// keep at least one boundary ahead after the rotation).
|
||||
var now = DateTime.UtcNow;
|
||||
var now = _timeProvider.GetUtcNow().UtcDateTime;
|
||||
var target = new DateTime(now.Year, now.Month, 1, 0, 0, 0, DateTimeKind.Utc).AddMonths(2);
|
||||
|
||||
var affected = 0;
|
||||
|
||||
Reference in New Issue
Block a user