diff --git a/sequencing-server/src/backgroundTranspiler.ts b/sequencing-server/src/backgroundTranspiler.ts index f78863f882..14b6b426f5 100644 --- a/sequencing-server/src/backgroundTranspiler.ts +++ b/sequencing-server/src/backgroundTranspiler.ts @@ -15,8 +15,8 @@ export async function backgroundTranspiler(numberOfThreads: number = 2) { } // Fetch latest mission model - const { mission_model_aggregate } = await getLatestMissionModel(graphqlClient); - if (!mission_model_aggregate) { + const { mission_model_aggregate: {aggregate: {max: {id: missionModelId} } } } = await getLatestMissionModel(graphqlClient); + if (!missionModelId) { console.log( '[ Background Transpiler ] Unable to fetch the latest mission model. Aborting background transpiling...', ); @@ -24,16 +24,14 @@ export async function backgroundTranspiler(numberOfThreads: number = 2) { } // Fetch latest command dictionary - const { command_dictionary_aggregate } = await getLatestCommandDictionary(graphqlClient); - if (!command_dictionary_aggregate) { + const { command_dictionary_aggregate: {aggregate: {max: {id: commandDictionaryId} } } } = await getLatestCommandDictionary(graphqlClient); + if (!commandDictionaryId) { console.log( '[ Background Transpiler ] Unable to fetch the latest command dictionary. Aborting background transpiling...', ); return; } - const commandDictionaryId = command_dictionary_aggregate.aggregate.max.id; - const missionModelId = mission_model_aggregate.aggregate.max.id; const { expansion_rule } = await getExpansionRule(graphqlClient, missionModelId, commandDictionaryId); if (expansion_rule === null || expansion_rule.length === 0) { @@ -51,7 +49,7 @@ export async function backgroundTranspiler(numberOfThreads: number = 2) { }); const commandTypes = await commandTypescriptDataLoader.load({ - dictionaryId: missionModelId, + dictionaryId: commandDictionaryId, }); if (commandTypes === null) { diff --git a/sequencing-server/src/utils/hasura.ts b/sequencing-server/src/utils/hasura.ts index 29beeb6f58..e6b64c6c01 100644 --- a/sequencing-server/src/utils/hasura.ts +++ b/sequencing-server/src/utils/hasura.ts @@ -453,7 +453,7 @@ export async function getExpansionRule( }>( gql` query GetExpansonLogic { - expansion_rule(where: {authoring_command_dict_id: {_eq: ${missionModelId}}, authoring_mission_model_id: {_eq: ${commandDictionaryId} }}) { + expansion_rule(where: {authoring_command_dict_id: {_eq: ${commandDictionaryId}}, authoring_mission_model_id: {_eq: ${missionModelId} }}) { id activity_type expansion_logic