Skip to content

Commit

Permalink
Merge pull request #212 from biothings/fix-855-bte
Browse files Browse the repository at this point in the history
fix: add `query_id` to inferred mode results if it exists
  • Loading branch information
tokebe authored Sep 17, 2024
2 parents f17021c + 85a26a5 commit 9bc677d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/inferred_mode/inferred_mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
TrapiAuxGraphCollection,
TrapiEdgeBinding,
TrapiKnowledgeGraph,
TrapiNodeBinding,
TrapiQEdge,
TrapiQNode,
TrapiQualifier,
Expand Down Expand Up @@ -296,10 +297,20 @@ export default class InferredQueryHandler {

// add results
newResponse.message.results.forEach((result) => {
// get query_ids populated by TRAPIQueryHandler.appendOriginalCuriesToResults
const subjectBinding: TrapiNodeBinding = { id: result.node_bindings.creativeQuerySubject[0].id, attributes: [] };
const objectBinding: TrapiNodeBinding = { id: result.node_bindings.creativeQueryObject[0].id, attributes: [] };
if (result.node_bindings.creativeQuerySubject[0].query_id !== undefined) {
subjectBinding.query_id = result.node_bindings.creativeQuerySubject[0].query_id;
}
if (result.node_bindings.creativeQueryObject[0].query_id !== undefined) {
objectBinding.query_id = result.node_bindings.creativeQueryObject[0].query_id;
}

const translatedResult: TrapiResult = {
node_bindings: {
[qEdge.subject]: [{ id: result.node_bindings.creativeQuerySubject[0].id, attributes: [] }],
[qEdge.object]: [{ id: result.node_bindings.creativeQueryObject[0].id, attributes: [] }],
[qEdge.subject]: [subjectBinding],
[qEdge.object]: [objectBinding],
},
pfocr: result.pfocr?.length ? result.pfocr : undefined,
analyses: [
Expand Down

0 comments on commit 9bc677d

Please sign in to comment.