mirror of
https://github.com/RuoJi6/ARTEX.git
synced 2026-11-12 05:33:50 +08:00
feat(tasks): stop tasks that miss a configurable findings checkpoint
This commit is contained in:
1 parent
39a8f2c31a
commit
997d2d98c0
24 files changed
+812
-64
No files matched your search
@@ -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
|
||||
}
|
||||
Reference in new issue
Block a user