mirror of
https://github.com/go-gitea/gitea
synced 2025-09-28 03:28:13 +00:00
feat: show step duration
This commit is contained in:
@@ -6,6 +6,7 @@ package bots
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
@@ -32,6 +33,18 @@ func (TaskStep) TableName() string {
|
||||
return "bots_task_step"
|
||||
}
|
||||
|
||||
func (step *TaskStep) TakeTime() time.Duration {
|
||||
if step.Started == 0 {
|
||||
return 0
|
||||
}
|
||||
started := step.Started.AsTime()
|
||||
if step.Status.IsDone() {
|
||||
return step.Stopped.AsTime().Sub(started)
|
||||
}
|
||||
step.Stopped.AsTime().Sub(started)
|
||||
return time.Since(started).Truncate(time.Second)
|
||||
}
|
||||
|
||||
func init() {
|
||||
db.RegisterModel(new(TaskStep))
|
||||
}
|
||||
|
Reference in New Issue
Block a user