Skip to content

Commit

Permalink
status now only updated if status has changed
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusDieckmann committed May 17, 2021
1 parent ae95165 commit 2dca884
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions endpoints/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,27 @@ func (apiHandler *BaktaJobAPI) GetJobsStatus(ctx context.Context, request *api.J
err = fmt.Errorf("JobID does not match secret ID")
return nil, err
}
newStatus, err := apiHandler.monitor.GetJobStatus(jobID.GetJobID())

job, err := apiHandler.dbHandler.GetJob(jobID.GetJobID())
if err != nil {
err = fmt.Errorf("could not get updated job status")
err = fmt.Errorf("could not find job")
return nil, err
}
err = apiHandler.dbHandler.UpdateStatus(jobID.GetJobID(), newStatus.Status, newStatus.ErrorMsg)

newStatus, err := apiHandler.monitor.GetJobStatus(jobID.GetJobID())
if err != nil {
err = fmt.Errorf("could not update job status")
err = fmt.Errorf("could not get updated job status")
return nil, err
}

if job.Status != newStatus.Status.String() {
err = apiHandler.dbHandler.UpdateStatus(jobID.GetJobID(), newStatus.Status, newStatus.ErrorMsg)
if err != nil {
err = fmt.Errorf("could not update job status")
return nil, err
}
}

jobIDs = append(jobIDs, jobID.JobID)
}

Expand Down

0 comments on commit 2dca884

Please sign in to comment.