mirror of
https://github.com/go-gitea/gitea.git
synced 2025-11-30 02:35:48 +01:00
Move run time reset logic to shared actions_service.ResetRunTimes function
This commit is contained in:
parent
aaf50824a7
commit
ef7f7e2a5c
@ -126,14 +126,9 @@ func RerunWorkflowRun(ctx *context.APIContext) {
|
||||
}
|
||||
|
||||
// Reset run's start and stop time when it is done
|
||||
if run.Status.IsDone() {
|
||||
run.PreviousDuration = run.Duration()
|
||||
run.Started = 0
|
||||
run.Stopped = 0
|
||||
if err := actions_model.UpdateRun(ctx, run, "started", "stopped", "previous_duration"); err != nil {
|
||||
ctx.APIErrorInternal(err)
|
||||
return
|
||||
}
|
||||
if err := actions_service.ResetRunTimes(ctx, run); err != nil {
|
||||
ctx.APIErrorInternal(err)
|
||||
return
|
||||
}
|
||||
|
||||
jobs, err := actions_model.GetRunJobsByRunID(ctx, run.ID)
|
||||
@ -425,14 +420,9 @@ func RerunWorkflowJob(ctx *context.APIContext) {
|
||||
}
|
||||
|
||||
// Reset run's start and stop time when it is done
|
||||
if run.Status.IsDone() {
|
||||
run.PreviousDuration = run.Duration()
|
||||
run.Started = 0
|
||||
run.Stopped = 0
|
||||
if err := actions_model.UpdateRun(ctx, run, "started", "stopped", "previous_duration"); err != nil {
|
||||
ctx.APIErrorInternal(err)
|
||||
return
|
||||
}
|
||||
if err := actions_service.ResetRunTimes(ctx, run); err != nil {
|
||||
ctx.APIErrorInternal(err)
|
||||
return
|
||||
}
|
||||
|
||||
// Get all jobs that need to be rerun (including dependencies)
|
||||
|
||||
@ -4,10 +4,23 @@
|
||||
package actions
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
actions_model "code.gitea.io/gitea/models/actions"
|
||||
"code.gitea.io/gitea/modules/container"
|
||||
)
|
||||
|
||||
// ResetRunTimes resets the start and stop times for a run when it is done, for rerun
|
||||
func ResetRunTimes(ctx context.Context, run *actions_model.ActionRun) error {
|
||||
if run.Status.IsDone() {
|
||||
run.PreviousDuration = run.Duration()
|
||||
run.Started = 0
|
||||
run.Stopped = 0
|
||||
return actions_model.UpdateRun(ctx, run, "started", "stopped", "previous_duration")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetAllRerunJobs get all jobs that need to be rerun when job should be rerun
|
||||
func GetAllRerunJobs(job *actions_model.ActionRunJob, allJobs []*actions_model.ActionRunJob) []*actions_model.ActionRunJob {
|
||||
rerunJobs := []*actions_model.ActionRunJob{job}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user