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
+2 -9
View File
@@ -82,15 +82,8 @@ func (run *ActionRun) LoadAttributes(ctx context.Context) error {
return nil
}
func (run *ActionRun) TakeTime() time.Duration {
if run.Started == 0 {
return 0
}
started := run.Started.AsTime()
if run.Status.IsDone() {
return run.Stopped.AsTime().Sub(started)
}
return time.Since(started).Truncate(time.Second)
func (run *ActionRun) Duration() time.Duration {
return calculateDuration(run.Started, run.Stopped, run.Status)
}
func (run *ActionRun) GetPushEventPayload() (*api.PushPayload, error) {