Skip to content

Commit

Permalink
fix: terminate on broken chain
Browse files Browse the repository at this point in the history
  • Loading branch information
tokebe committed Mar 22, 2024
1 parent 559de80 commit e602f5a
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/edge_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export default class QueryEdgeManager {
return keep;
}

collectRecords(): void {
collectRecords(): boolean {
//go through edges and collect records organized by edge
let recordsByQEdgeID: RecordsByQEdgeID = {};
//all res merged
Expand Down Expand Up @@ -268,12 +268,10 @@ export default class QueryEdgeManager {
new LogEntry(
'WARNING',
null,
`qEdges ${JSON.stringify(brokenEdges)} ` + `resulted in (0) records. No complete paths can be formed.`,
`qEdges ${brokenEdges} resulted in (0) records. No complete paths can be formed.`,
).getLog(),
);
debug(
`(12) qEdges ${JSON.stringify(brokenEdges)} ` + `resulted in (0) records. No complete paths can be formed.`,
);
debug(`(12) qEdges ${brokenEdges} resulted in (0) records. No complete paths can be formed.`);
}
//Organized by edge: update query records
this._organizedRecords = recordsByQEdgeID;
Expand All @@ -289,8 +287,12 @@ export default class QueryEdgeManager {
// console.log(err);
// }
// });
debug(`(12) Collected (${this._records.length}) records!`);
this.logs.push(new LogEntry('DEBUG', null, `Edge manager collected (${this._records.length}) records!`).getLog());
if (!brokenChain) {
debug(`(12) Collected (${this._records.length}) records!`);
this.logs.push(new LogEntry('DEBUG', null, `Edge manager collected (${this._records.length}) records!`).getLog());
}

return !brokenChain;
}

updateEdgeRecords(currentQEdge: QEdge): void {
Expand Down Expand Up @@ -474,7 +476,13 @@ export default class QueryEdgeManager {
}
this._logSkippedQueries(unavailableAPIs);
// collect and organize records
this.collectRecords();
if (!this.collectRecords()) {
debug(`(X) Terminating...No complete paths.`);
this.logs.push(
new LogEntry('WARNING', null, `No complete paths could be formed. Your query terminates.`).getLog(),
);
return;
}
// dump records if set to do so
if (process.env.DUMP_RECORDS) {
await this.dumpRecords(this.getRecords());
Expand Down

0 comments on commit e602f5a

Please sign in to comment.