fix(deployment): purge SystemArtifactDeploymentRecords in the terminal-record retention sweep (review 2026-10-21 08/G2)
This commit is contained in:
+23
@@ -285,6 +285,29 @@ public class DeploymentManagerRepository : IDeploymentManagerRepository
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<int> PurgeSystemArtifactDeploymentRecordsAsync(
|
||||
DateTimeOffset cutoffUtc,
|
||||
int batchSize,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
// Same bounded-batch shape as PurgeTerminalDeploymentRecordsAsync: the caller
|
||||
// re-invokes until fewer than batchSize rows come back. Every row is terminal by
|
||||
// construction (it is written once, after the artifact sweep finished).
|
||||
var stale = await _dbContext.SystemArtifactDeploymentRecords
|
||||
.Where(d => d.DeployedAt < cutoffUtc)
|
||||
.OrderBy(d => d.Id)
|
||||
.Take(batchSize)
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
if (stale.Count == 0)
|
||||
return 0;
|
||||
|
||||
_dbContext.SystemArtifactDeploymentRecords.RemoveRange(stale);
|
||||
await _dbContext.SaveChangesAsync(cancellationToken);
|
||||
return stale.Count;
|
||||
}
|
||||
|
||||
// --- DeployedConfigSnapshot ---
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
Reference in New Issue
Block a user