🐛 ⚙️ Correction de l'algorithme des variations

pull/281/head
Mael 2018-09-04 17:17:36 +02:00
parent 097f4b70ad
commit a53851e300
1 changed files with 12 additions and 5 deletions

View File

@ -1,5 +1,6 @@
import {
reduce,
reduced,
mergeWith,
objOf,
toPairs,
@ -159,11 +160,17 @@ export let mecanismVariations = (recurse, k, v, devariate) => {
: evaluateNode(cache, situationGate, parsedRules, prop)
),
evaluatedExplanation = map(evaluateVariation, node.explanation),
satisfiedVariation = find(
variation =>
!variation.condition || variation.condition.nodeValue === true,
evaluatedExplanation
),
satisfiedVariation = reduce(
(_, variation) =>
variation.condition == undefined
? reduced(variation) // We've reached the eventual defaut case
: variation.condition.nodeValue === null
? reduced(null) // one case has missing variables => we can't go further
: variation.condition.nodeValue === true
? reduced(variation)
: null,
null
)(evaluatedExplanation),
nodeValue = satisfiedVariation
? satisfiedVariation.consequence.nodeValue
: null