From a15bda7f3f889c4372fe933dddaab68e81a0927b Mon Sep 17 00:00:00 2001 From: adrienmaillard <94930916+adrienmaillard@users.noreply.github.com> Date: Mon, 18 Dec 2023 10:35:44 -0800 Subject: [PATCH] Refresh simulation results after scheduling (#1055) Refresh results after scheduling --- src/types/scheduling.ts | 1 + src/utilities/effects.ts | 14 +++++++++++++- src/utilities/gql.ts | 9 +++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/types/scheduling.ts b/src/types/scheduling.ts index dfc416f1db..f841c89d02 100644 --- a/src/types/scheduling.ts +++ b/src/types/scheduling.ts @@ -69,6 +69,7 @@ export type SchedulingGoalInsertInput = Omit< >; export type SchedulingResponse = { + datasetId: number | null; reason: SchedulingError; status: 'complete' | 'failed' | 'incomplete'; }; diff --git a/src/utilities/effects.ts b/src/utilities/effects.ts index c9090f936f..3d5040f0bc 100644 --- a/src/utilities/effects.ts +++ b/src/utilities/effects.ts @@ -3705,11 +3705,23 @@ const effects = { const data = await reqHasura(gql.SCHEDULE, { specificationId }, user); const { schedule } = data; if (schedule != null) { - const { reason, status } = schedule; + const { datasetId, reason, status } = schedule; if (status === 'complete') { schedulingStatus.set(Status.Complete); incomplete = false; + if (datasetId != null) { + const simDatasetIdData = await reqHasura<{ id: number }>( + gql.GET_SIMULATION_DATASET_ID, + { datasetId }, + user, + ); + const { simulation_dataset } = simDatasetIdData; + // the request above will return either 0 or 1 element + if (Array.isArray(simulation_dataset) && simulation_dataset.length > 0) { + simulationDatasetId.set(simulation_dataset[0].id); + } + } showSuccessToast(`Scheduling ${analysis_only ? 'Analysis ' : ''}Complete`); } else if (status === 'failed') { schedulingStatus.set(Status.Failed); diff --git a/src/utilities/gql.ts b/src/utilities/gql.ts index 0579370610..ac6ad6621b 100644 --- a/src/utilities/gql.ts +++ b/src/utilities/gql.ts @@ -1158,6 +1158,14 @@ const gql = { } `, + GET_SIMULATION_DATASET_ID: `#graphql + query GetSimulationDatasetId($datasetId: Int!) { + simulation_dataset(where: {dataset_id: {_eq: $datasetId}}) { + id + } + } + `, + GET_SPANS: `#graphql query GetSpans($datasetId: Int!) { span(where: { dataset_id: { _eq: $datasetId } }, order_by: { start_offset: asc }) { @@ -1399,6 +1407,7 @@ const gql = { schedule(specificationId: $specificationId) { reason status + datasetId } } `,