Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make FetchChildren use GetJobs #26

Merged
merged 1 commit into from
Mar 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Make FetchChildren use GetJobs
Make fetching child jobs use the new one-request GetJobs method as well.
  • Loading branch information
grisu48 committed Mar 30, 2023
commit ec26b3baf5f760a6e0b3c54ec747acb9fa6c4239
25 changes: 16 additions & 9 deletions gopenqa.go
Original file line number Diff line number Diff line change
Expand Up @@ -635,17 +635,24 @@ func mergeParams(params map[string]string) string {
* Fetch the given child jobs. Use with j.Children.Chained, j.Children.DirectlyChained and j.Children.Parallel
* if follow is set to true, the method will return the cloned job instead of the original one, if present
*/
func (j *Job) FetchChildren(children []int64, follow bool) ([]Job, error) {
jobs := make([]Job, 0)
for _, id := range children {
job, err := j.instance.GetJobFollow(id)
if err != nil {
return jobs, err
func (j *Job) FetchChildren(ids []int64, follow bool) ([]Job, error) {
children, err := j.instance.GetJobs(ids)
if err != nil {
return children, err
}
if follow {
for i, job := range children {
// Fetch cloned job, if present
if job.CloneID != 0 && job.CloneID != job.ID {
job, err := j.instance.GetJobFollow(job.ID)
if err != nil {
return children, err
}
children[i] = job
}
}
jobs = append(jobs, job)
}

return jobs, nil
return children, nil
}

/* Fetch all child jobs
Expand Down