61 lines
1.9 KiB
C#
61 lines
1.9 KiB
C#
// -----------------------------------------------------------------------------
|
|
// ArtifactMigrationState.cs
|
|
// Sprint: SPRINT_20260118_017_Evidence_artifact_store_unification
|
|
// Task: AS-006 - Migrate existing evidence to unified store
|
|
// Description: Tracks migration progress state
|
|
// -----------------------------------------------------------------------------
|
|
namespace StellaOps.Artifact.Infrastructure;
|
|
|
|
internal sealed class ArtifactMigrationState
|
|
{
|
|
private readonly TimeProvider _timeProvider;
|
|
|
|
public ArtifactMigrationState(int totalItems, TimeProvider timeProvider)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(timeProvider);
|
|
_timeProvider = timeProvider;
|
|
TotalItems = totalItems;
|
|
StartedAt = _timeProvider.GetUtcNow();
|
|
LastUpdateAt = StartedAt;
|
|
}
|
|
|
|
public int TotalItems { get; }
|
|
public int ProcessedItems { get; private set; }
|
|
public int SuccessCount { get; private set; }
|
|
public int FailureCount { get; private set; }
|
|
public int SkippedCount { get; private set; }
|
|
public DateTimeOffset StartedAt { get; }
|
|
public DateTimeOffset LastUpdateAt { get; private set; }
|
|
|
|
public MigrationProgress Apply(ArtifactMigrationResult result)
|
|
{
|
|
ProcessedItems++;
|
|
if (result.Success && !result.Skipped)
|
|
{
|
|
SuccessCount++;
|
|
}
|
|
else if (result.Skipped)
|
|
{
|
|
SkippedCount++;
|
|
}
|
|
else
|
|
{
|
|
FailureCount++;
|
|
}
|
|
|
|
LastUpdateAt = _timeProvider.GetUtcNow();
|
|
|
|
return new MigrationProgress
|
|
{
|
|
TotalItems = TotalItems,
|
|
ProcessedItems = ProcessedItems,
|
|
SuccessCount = SuccessCount,
|
|
FailureCount = FailureCount,
|
|
SkippedCount = SkippedCount,
|
|
StartedAt = StartedAt,
|
|
LastUpdateAt = LastUpdateAt,
|
|
CurrentItem = result.OriginalPath
|
|
};
|
|
}
|
|
}
|