fix ShouldBlockRunByConcurrency

pull/32751/head
Zettat123 5 days ago
parent 93af0ee518
commit 5932c145dd
  1. 7
      models/actions/run.go

@ -373,14 +373,15 @@ func ShouldBlockRunByConcurrency(ctx context.Context, actionRun *ActionRun) (boo
return false, nil return false, nil
} }
concurrentRunsNum, err := db.Count[ActionRun](ctx, &FindRunOptions{ concurrentRuns, err := db.Find[ActionRun](ctx, &FindRunOptions{
RepoID: actionRun.RepoID, RepoID: actionRun.RepoID,
ConcurrencyGroup: actionRun.ConcurrencyGroup, ConcurrencyGroup: actionRun.ConcurrencyGroup,
Status: []Status{StatusWaiting, StatusRunning}, Status: []Status{StatusWaiting, StatusRunning},
}) })
if err != nil { if err != nil {
return false, fmt.Errorf("count running and waiting runs: %w", err) return false, fmt.Errorf("find running and waiting runs: %w", err)
} }
previousRuns := slices.DeleteFunc(concurrentRuns, func(r *ActionRun) bool { return r.ID == actionRun.ID })
return concurrentRunsNum > 0, nil return len(previousRuns) > 0, nil
} }

Loading…
Cancel
Save