|
500 | 500 | credentials: 'include' |
501 | 501 | } |
502 | 502 | ); |
503 | | - const receivedStatuses = await statusResponse.json(); |
504 | 503 | if (!statusResponse.ok) { |
505 | | - console.error('Error retrieving images status', receivedStatuses); |
| 504 | + console.error('Error retrieving images status'); |
506 | 505 | return; |
507 | 506 | } |
| 507 | + const receivedStatuses = await statusResponse.json(); |
508 | 508 | const jobHasError = selectedSubmittedJob?.status === 'failed'; |
509 | 509 | statuses = Object.fromEntries(Object.entries(receivedStatuses).filter(([, v]) => v !== null)); |
510 | 510 | if (selectedSubmittedJob && Object.keys(statuses).length === 0) { |
|
515 | 515 | const submitted = Object.values(statuses).filter((s) => s.status === 'submitted'); |
516 | 516 | if (submitted.length > 0 || selectedSubmittedJob?.status === 'submitted') { |
517 | 517 | window.clearTimeout(statusWatcherTimer); |
518 | | - statusWatcherTimer = window.setTimeout(loadJobsStatus, updateJobsInterval); |
| 518 | + // if there are no null statuses and no submitted statuses the job is completed, |
| 519 | + // so we can reload the latest job immediately, otherwise wait default timeout |
| 520 | + const allCompleted = |
| 521 | + Object.entries(receivedStatuses).length === Object.values(statuses).length && |
| 522 | + submitted.length === 0; |
| 523 | + statusWatcherTimer = window.setTimeout(loadJobsStatus, allCompleted ? 0 : updateJobsInterval); |
519 | 524 | } else { |
520 | 525 | await reloadSelectedDataset(); |
521 | 526 | selectedSubmittedJob = undefined; |
|
603 | 608 | * @return {Promise<import('fractal-components/types/api').ApplyWorkflowV2|undefined>} |
604 | 609 | */ |
605 | 610 | async function getSelectedJob(datasetId) { |
606 | | - const submitted = Object.values(statuses).filter((s) => s.num_submitted_images > 0); |
| 611 | + const submitted = Object.values(statuses).filter((s) => s.status === 'submitted'); |
607 | 612 | if ( |
608 | 613 | submitted.length > 0 && |
609 | 614 | selectedSubmittedJob && |
|
0 commit comments