namespace StellaOps.Feedser.Core.Jobs;

/// <summary>
/// Immutable projection of a job run as stored in persistence.
/// </summary>
public sealed record JobRunSnapshot(
    Guid RunId,
    string Kind,
    JobRunStatus Status,
    DateTimeOffset CreatedAt,
    DateTimeOffset? StartedAt,
    DateTimeOffset? CompletedAt,
    string Trigger,
    string? ParametersHash,
    string? Error,
    TimeSpan? Timeout,
    TimeSpan? LeaseDuration,
    IReadOnlyDictionary<string, object?> Parameters)
{
    public TimeSpan? Duration => StartedAt is null || CompletedAt is null ? null : CompletedAt - StartedAt;
}
