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 18, 2023
1 parent 3a86919 commit 5e5cdf4
Show file tree
Hide file tree
Showing 3 changed files with 23 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
14 changes: 13 additions & 1 deletion src/utilities/effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3705,11 +3705,23 @@ 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.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);
Expand Down
9 changes: 9 additions & 0 deletions src/utilities/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) {
Expand Down Expand Up @@ -1399,6 +1407,7 @@ const gql = {
schedule(specificationId: $specificationId) {
reason
status
datasetId
}
}
`,
Expand Down

0 comments on commit 5e5cdf4

Please sign in to comment.