Skip to content

Commit

Permalink
Correction To Simulation Pollers (#5968)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom-Szendrey authored Jan 6, 2025
1 parent 32d42c2 commit 05020db
Showing 1 changed file with 27 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,33 +246,37 @@ const pollResult = async (runId: string) => {
return pollerResults;
};
async function processPolling(id, propName, inProgressPropName) {
const response = await pollResult(id);
if (response.state === PollerState.Done) {
const state = _.cloneDeep(props.node.state);
state[propName] = id;
state[inProgressPropName] = '';
emit('update-state', state);
if (propName === 'forecastId') {
await processResult(id); // Only process and output result for main forecast
}
}
}
watch(
() => props.node.state.inProgressForecastId,
() => props.node.state.inProgressForecastId + props.node.state.inProgressBaseForecastId,
async (id) => {
if (!id || id === '') return;
await processPolling(id, 'forecastId', 'inProgressForecastId');
},
{ immediate: true }
);
watch(
() => props.node.state.inProgressBaseForecastId,
async (id) => {
if (!id || id === '') return;
await processPolling(id, 'baseForecastId', 'inProgressBaseForecastId');
let doneProcess = true;
let response;
if (props.node.state.inProgressBaseForecastId) {
const baseForecastId = props.node.state.inProgressBaseForecastId;
response = await pollResult(baseForecastId);
}
if (response?.state && response.state !== PollerState.Done) {
doneProcess = false;
}
if (props.node.state.inProgressForecastId) {
const forecastId = props.node.state.inProgressForecastId;
response = await pollResult(forecastId);
}
if (response?.state && response.state !== PollerState.Done) {
doneProcess = false;
}
if (doneProcess) {
const state = _.cloneDeep(props.node.state);
state.forecastId = state.inProgressForecastId;
state.baseForecastId = state.inProgressBaseForecastId;
state.inProgressForecastId = '';
state.inProgressBaseForecastId = '';
emit('update-state', state);
await processResult(state.forecastId); // Only process and output result for main forecast
}
},
{ immediate: true }
);
Expand Down

0 comments on commit 05020db

Please sign in to comment.