⚙️ Corrige l'évaluation de 'une de ces conditions'

pull/37/head
Laurent Bossavit 2017-08-18 17:21:43 +02:00
parent 2633d07639
commit d80287a4d2
4 changed files with 12401 additions and 5 deletions

12378
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -19,11 +19,11 @@ export let rewriteNode = (node, nodeValue, explanation, collectMissing) =>
explanation
})
export let evaluateArray = (reducer, start, nullable = true) => (situationGate, parsedRules, node) => {
export let evaluateArray = (reducer, start) => (situationGate, parsedRules, node) => {
let evaluateOne = child => evaluateNode(situationGate, parsedRules, child),
explanation = R.map(evaluateOne, node.explanation),
values = R.pluck("nodeValue",explanation),
nodeValue = (nullable && R.any(R.equals(null),values)) ? null : R.reduce(reducer, start, values)
nodeValue = R.any(R.equals(null),values) ? null : R.reduce(reducer, start, values)
let collectMissing = node => node.nodeValue == null ? R.chain(collectNodeMissing,node.explanation) : []
return rewriteNode(node,nodeValue,explanation,collectMissing)

View File

@ -84,8 +84,19 @@ export let mecanismOneOf = (recurse, k, v) => {
}
/>
let evaluate = (situationGate, parsedRules, node) => {
let evaluateOne = child => evaluateNode(situationGate, parsedRules, child),
explanation = R.map(evaluateOne, node.explanation),
values = R.pluck("nodeValue",explanation),
nodeValue = R.any(R.equals(true),values) ? true :
(R.any(R.equals(null),values) ? null : false)
let collectMissing = node => node.nodeValue == null ? R.chain(collectNodeMissing,node.explanation) : []
return rewriteNode(node,nodeValue,explanation,collectMissing)
}
return {
evaluate: evaluateArray(R.or, false, false), // null values do not make the whole array null
evaluate,
jsx,
explanation,
category: 'mecanism',

View File

@ -17,9 +17,16 @@
situation:
dégradation mineure: oui
valeur attendue: 0
variables manquantes: []
- nom: Est fausse -> en attente de l'autre
situation:
dégradation majeure: non
valeur attendue: null
# variables manquantes:
# - dégradation mineure
variables manquantes:
- dégradation mineure
- nom: Toutes fausses -> valeur de la formule
situation:
dégradation mineure: non
dégradation majeure: non
valeur attendue: 3000
variables manquantes: []