feat: calculate duration

This commit is contained in:
Jason Song
2023-01-05 16:19:08 +08:00
parent c510fdbcf1
commit a4b2cf2426
8 changed files with 82 additions and 39 deletions

View File

@@ -43,16 +43,8 @@ func init() {
db.RegisterModel(new(ActionRunJob))
}
func (job *ActionRunJob) TakeTime() time.Duration {
if job.Started == 0 {
return 0
}
started := job.Started.AsTime()
if job.Status.IsDone() {
return job.Stopped.AsTime().Sub(started)
}
job.Stopped.AsTime().Sub(started)
return time.Since(started).Truncate(time.Second)
func (job *ActionRunJob) Duration() time.Duration {
return calculateDuration(job.Started, job.Stopped, job.Status)
}
func (job *ActionRunJob) LoadRun(ctx context.Context) error {