Skip to content

Commit

Permalink
Merge pull request #191 from grisu48/panic
Browse files Browse the repository at this point in the history
Fix panic when RequestJobLimit is not set
  • Loading branch information
grisu48 authored Jan 15, 2025
2 parents 8807bb9 + a927c92 commit e4d1a27
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions cmd/openqa-revtui/openqa-revtui.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func parseProgramArgs(cf *Config) ([]Config, error) {
}
filename := os.Args[i]
var cf Config
cf.RequestJobLimit = 100 // Set default limit
if err := cf.LoadToml(filename); err != nil {
return cfs, fmt.Errorf("in %s: %s", filename, err)
}
Expand Down
8 changes: 6 additions & 2 deletions cmd/openqa-revtui/openqa.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,13 @@ func fetchJobsFollow(ids []int64, model *TUIModel, progress func(i, n int)) ([]g
// We split the job ids into multiple requests if necessary
jobs := make([]gopenqa.Job, 0)
// Progress variables
chunks := len(ids) / model.Config.RequestJobLimit
limit := model.Config.RequestJobLimit
if limit <= 0 {
limit = len(ids)
}
chunks := len(ids) / limit
for i := 0; len(ids) > 0; i++ { // Repeat until no more ids are available.
n := min(model.Config.RequestJobLimit, len(ids))
n := min(limit, len(ids))
chunk, err := model.Instance.GetJobsFollow(ids[:n])
if progress != nil {
progress(i, chunks)
Expand Down

0 comments on commit e4d1a27

Please sign in to comment.