⚙️ Corrige l'évaluation de 'une de ces conditions'
parent
2633d07639
commit
d80287a4d2
File diff suppressed because it is too large
Load Diff
|
@ -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)
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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: []
|
||||
|
|
Loading…
Reference in New Issue