Skip to content

Commit

Permalink
fix aux graph while loop
Browse files Browse the repository at this point in the history
  • Loading branch information
rjawesome committed Apr 17, 2024
1 parent f861412 commit 82bd2d6
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/inferred_mode/inferred_mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ export default class InferredQueryHandler {
// modified count used for pathfinder
const pfIntermediateSet = new Set();

let auxGraphSuffixes: {[inferredEdgeID: string]: number} = {};
// add results
newResponse.message.results.forEach((result) => {
const translatedResult: TrapiResult = {
Expand Down Expand Up @@ -356,13 +357,9 @@ export default class InferredQueryHandler {
attributes: [{ attribute_type_id: 'biolink:support_graphs', value: [] }],
};
}
let auxGraphSuffix = 0;
while (
Object.keys(combinedResponse.message.auxiliary_graphs).includes(`${inferredEdgeID}-support${auxGraphSuffix}`)
) {
auxGraphSuffix += 1;
}
const auxGraphID = `${inferredEdgeID}-support${auxGraphSuffix}`;
if (!auxGraphSuffixes[inferredEdgeID]) auxGraphSuffixes[inferredEdgeID] = 0;
const auxGraphID = `${inferredEdgeID}-support${auxGraphSuffixes[inferredEdgeID]}`;
auxGraphSuffixes[inferredEdgeID]++;
(combinedResponse.message.knowledge_graph.edges[inferredEdgeID].attributes[0].value as string[]).push(
auxGraphID,
);
Expand Down

0 comments on commit 82bd2d6

Please sign in to comment.