runner/seed, app/service: seed run-time stats from log files (T2.5)

Add SeedStats, which reconstructs per-job execution-time aggregates from
existing log files: suffix-matched by sanitized job name, bounded by
MaxLogFiles, and tolerant of duration-less legacy logs (counted in
run/fail totals but excluded from last/avg/max). NewService folds the
seed into each JobRuntime at build time so stats survive a restart.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
mixeme
2026-06-24 08:16:47 +03:00
parent 7dafa82b21
commit 6c69f323bd
2 changed files with 154 additions and 0 deletions
+14
View File
@@ -93,6 +93,20 @@ func NewService(store *storage.Store, jobs []domain.Job) *Service {
s.parseScheduleLocked(job)
s.refreshNextRunFromLocked(job, s.runtimes[job.ID], now)
}
// Seed execution-time statistics from existing log files so the details panel
// shows accumulated run history immediately after a restart, not just runs
// since this process started.
for id, seed := range runner.SeedStats(store.Paths.LogsDir, jobs, store.Config.MaxLogFiles) {
runtime := s.runtimes[id]
if runtime == nil {
continue
}
runtime.RunCount = seed.RunCount
runtime.FailCount = seed.FailCount
runtime.LastDurationMS = seed.LastDurationMS
runtime.AvgDurationMS = seed.AvgDurationMS
runtime.MaxDurationMS = seed.MaxDurationMS
}
return s
}