Skip to content

Commit

Permalink
Refresh results after scheduling
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienmaillard committed Dec 13, 2023
1 parent 55241e0 commit 0babfad
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/types/scheduling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export type SchedulingGoalInsertInput = Omit<
>;

export type SchedulingResponse = {
datasetId: number | null;
reason: SchedulingError;
status: 'complete' | 'failed' | 'incomplete';
};
Expand Down
17 changes: 16 additions & 1 deletion src/utilities/effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3700,11 +3700,26 @@ const effects = {
const data = await reqHasura<SchedulingResponse>(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.SIMULATION_DATASET_ID,
{ datasetId },
user,
);
const { simulation_dataset } = simDatasetIdData;
if (Array.isArray(simulation_dataset) && simulation_dataset.length > 0) {
simulationDatasetId.set(simulation_dataset[0].id);
} else {
throw Error(
`Unable to find simulation dataset with dataset id: "${datasetId}" and update the simulation results after scheduling.`,
);
}
}
showSuccessToast(`Scheduling ${analysis_only ? 'Analysis ' : ''}Complete`);
} else if (status === 'failed') {
schedulingStatus.set(Status.Failed);
Expand Down
9 changes: 9 additions & 0 deletions src/utilities/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1391,6 +1391,7 @@ const gql = {
schedule(specificationId: $specificationId) {
reason
status
datasetId
}
}
`,
Expand All @@ -1405,6 +1406,14 @@ const gql = {
}
`,

SIMULATION_DATASET_ID: `#graphql
query GetSimulationDatasetId($datasetId: Int!) {
simulation_dataset(where: {dataset_id: {_eq: $datasetId}}) {
id
}
}
`,

SUB_ACTIVITY_DIRECTIVES: `#graphql
subscription SubActivityDirectives($planId: Int!) {
activity_directives: activity_directive(where: { plan_id: { _eq: $planId } }, order_by: { start_offset: asc }) {
Expand Down

0 comments on commit 0babfad

Please sign in to comment.