feat(tasks): stop tasks that miss a configurable findings checkpoint

This commit is contained in:
ji ruo committed 2026-11-11 14:07:39 +08:00
1 parent 39a8f2c31a
commit 997d2d98c0
24 files changed
+812 -64

No files matched your search

+11
View File
@@ -1,5 +1,7 @@
package server
import "time"
// taskRunSeconds computes displayed active runtime from persisted segment data.
// Segment timestamps are unix seconds; a zero start means no active segment.
func taskRunSeconds(active, segmentStarted, now int64, status string, paused, queued bool) int64 {
@@ -23,3 +25,12 @@ func finalizeTaskRunSeconds(active, segmentStarted, now int64) (int64, int64) {
}
return active, 0
}
// noResultRemaining excludes pauses, queue time and closed schedule windows by
// using the same active execution segments as the task runtime display.
func noResultRemaining(seconds int, state taskLifecycleState, now int64) time.Duration {
runtime := taskRunSeconds(state.ActiveRunSeconds, state.RunSegmentStartedAt, now, state.Status, state.Paused, state.Queued)
elapsed := max(int64(0), runtime-state.NoResultBaseSeconds)
remaining := max(int64(0), int64(seconds)-elapsed)
return time.Duration(remaining) * time.Second
}