fix: allow partial evaluation of checks in jsonfc factchecker

This change should fix the entity check endpoint when some facts are
missing, e.g. the retriever has not run yet.

Signed-off-by: Jacob Wejendorp <jwe@tradeshift.com>
This commit is contained in:
Jacob Wejendorp
2021-12-16 14:40:31 +01:00
parent a3ec122170
commit c88d8339a3
@@ -88,7 +88,13 @@ export class JsonRulesEngineFactChecker
techInsightChecks.forEach(techInsightCheck => {
const rule = techInsightCheck.rule;
rule.name = techInsightCheck.id;
engine.addRule({ ...techInsightCheck.rule, event: noopEvent });
// Only run checks that have all the facts available:
const hasAllFacts = techInsightCheck.factIds.every(
retrieverId => !!facts[retrieverId],
);
if (hasAllFacts) {
engine.addRule({ ...techInsightCheck.rule, event: noopEvent });
}
});
const factValues = Object.values(facts).reduce(
(acc, it) => ({ ...acc, ...it.facts }),