Count short gaps at the edges of the soak window as covered (refs #53)
The scheduler's first jobs finish about a minute after the bot starts, so a run started exactly at the window's start was reported as covering slightly less than 48 hours. A gap shorter than the allowed silence (15 minutes) at either edge now counts as covered, like one in the middle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
be6d5fb91f
commit
1c7205024f
2 files changed
+5
-3
No files matched your search
@@ -83,8 +83,10 @@ public static class SoakReporter
|
||||
.ConfigureAwait(false);
|
||||
var absences = await s.QueryAsync("SELECT started_at, ended_at FROM absences WHERE ended_at >= @from AND started_at <= @to ORDER BY started_at",
|
||||
r => (Start: r.Moment("started_at"), End: r.Moment("ended_at")), window).ConfigureAwait(false);
|
||||
var start = jobs.First is { } first && first > from ? first : from;
|
||||
var end = jobs.Last is { } lastJob && lastJob < to ? lastJob : to;
|
||||
// A gap shorter than the longest silence allowed at either end (the first jobs come a minute after the start,
|
||||
// the last one up to 5 minutes before the end) is no more a hole than one in the middle.
|
||||
var start = jobs.First is { } first && first > from + MaxSilence ? first : from;
|
||||
var end = jobs.Last is { } lastJob && lastJob < to - MaxSilence ? lastJob : to;
|
||||
var covered = jobs.First is null || jobs.Last is null || end <= start ? TimeSpan.Zero
|
||||
: end - start - absences.Aggregate(TimeSpan.Zero, (sum, a) => sum + (Min(a.End, end) - Max(a.Start, start) is { } span && span > TimeSpan.Zero ? span : TimeSpan.Zero));
|
||||
checks.Add(new SoakCheck($"Durata coperta dal lavoro del bot: {SoakReport.Hours(covered)} (servono almeno {SoakReport.Hours(minimum)}).", covered >= minimum));
|
||||
|
||||
@@ -54,7 +54,7 @@ public sealed class SoakReportTests
|
||||
var text = report.Markdown(Zones.Rome);
|
||||
Assert.IsTrue(report.Passed, text);
|
||||
Assert.Contains("**Esito: regolare.**", text);
|
||||
Assert.Contains("Durata coperta dal lavoro del bot: 49,0 ore", text);
|
||||
Assert.Contains("Durata coperta dal lavoro del bot: 49 ore", text);
|
||||
Assert.Contains("Al lavoro dall'inizio alla fine della finestra.", text);
|
||||
Assert.Contains("Ogni conto riconciliato fino alla fine e in regola: ", text);
|
||||
Assert.Contains("Decisioni di crypto_trend: 2 su 2 chiusure giornaliere.", text);
|
||||
|
||||
Reference in new issue
Block a user