Simplifie le calcul des variables manquantes (5)
parent
6ff8488265
commit
768e7aee6b
|
@ -43,13 +43,10 @@ export let evaluateArray = (reducer, start) => (
|
|||
? null
|
||||
: reduce(reducer, start, values),
|
||||
missingVariables = node.nodeValue == null
|
||||
? chain(collectNodeMissing, explanation)
|
||||
? map(collectNodeMissing, explanation)
|
||||
: []
|
||||
|
||||
return {
|
||||
...rewriteNode(node, nodeValue, explanation),
|
||||
missingVariables
|
||||
}
|
||||
return rewriteNode(node, nodeValue, explanation, missingVariables)
|
||||
}
|
||||
|
||||
export let evaluateArrayWithFilter = (evaluationFilter, reducer, start) => (
|
||||
|
@ -69,13 +66,10 @@ export let evaluateArrayWithFilter = (evaluationFilter, reducer, start) => (
|
|||
? null
|
||||
: reduce(reducer, start, values),
|
||||
missingVariables = node.nodeValue == null
|
||||
? chain(collectNodeMissing, explanation)
|
||||
? map(collectNodeMissing, explanation)
|
||||
: []
|
||||
|
||||
return {
|
||||
...rewriteNode(node, nodeValue, explanation),
|
||||
missingVariables
|
||||
}
|
||||
return rewriteNode(node, nodeValue, explanation, missingVariables)
|
||||
}
|
||||
|
||||
export let parseObject = (recurse, objectShape, value) => {
|
||||
|
@ -99,10 +93,7 @@ export let evaluateObject = (objectShape, effect) => (
|
|||
let transforms = map(k => [k, evaluateOne], keys(objectShape)),
|
||||
explanation = evolve(fromPairs(transforms))(node.explanation),
|
||||
nodeValue = effect(explanation),
|
||||
missingVariables = chain(collectNodeMissing, values(explanation))
|
||||
missingVariables = map(collectNodeMissing, values(explanation))
|
||||
|
||||
return {
|
||||
...rewriteNode(node, nodeValue, explanation),
|
||||
missingVariables
|
||||
}
|
||||
return rewriteNode(node, nodeValue, explanation, missingVariables)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import {
|
||||
chain,
|
||||
flatten,
|
||||
pluck,
|
||||
groupBy,
|
||||
toPairs,
|
||||
sort,
|
||||
|
@ -22,7 +23,6 @@ import SelectAtmp from 'Components/conversation/select/SelectTauxRisque'
|
|||
import formValueTypes from 'Components/conversation/formValueTypes'
|
||||
|
||||
import { findRuleByDottedName, disambiguateRuleReference } from './rules'
|
||||
import { collectNodeMissing } from './evaluation'
|
||||
|
||||
/*
|
||||
COLLECTE DES VARIABLES MANQUANTES
|
||||
|
@ -40,7 +40,7 @@ import { collectNodeMissing } from './evaluation'
|
|||
*/
|
||||
|
||||
export let collectMissingVariables = targets => {
|
||||
let missing = chain(collectNodeMissing, targets)
|
||||
let missing = flatten(pluck('missingVariables', targets))
|
||||
return groupBy(identity, missing)
|
||||
}
|
||||
|
||||
|
|
|
@ -150,11 +150,11 @@ let devariate = (recurse, k, v) => {
|
|||
let leftMissing = choice
|
||||
? []
|
||||
: uniq(
|
||||
chain(collectNodeMissing, pluck('condition', explanation))
|
||||
map(collectNodeMissing, pluck('condition', explanation))
|
||||
),
|
||||
rightMissing = choice
|
||||
? choice.missingVariables
|
||||
: chain(collectNodeMissing, explanation),
|
||||
: map(collectNodeMissing, explanation),
|
||||
missingVariables = concat(leftMissing, rightMissing || [])
|
||||
|
||||
return rewriteNode(node, nodeValue, explanation, missingVariables)
|
||||
|
@ -219,7 +219,7 @@ export let mecanismOneOf = (recurse, k, v) => {
|
|||
nodeValue = any(equals(true), values)
|
||||
? true
|
||||
: any(equals(null), values) ? null : false,
|
||||
missingVariables = nodeValue == null ? chain(collectNodeMissing, explanation) : []
|
||||
missingVariables = nodeValue == null ? map(collectNodeMissing, explanation) : []
|
||||
|
||||
return rewriteNode(node, nodeValue, explanation, missingVariables)
|
||||
}
|
||||
|
@ -262,7 +262,7 @@ export let mecanismAllOf = (recurse, k, v) => {
|
|||
nodeValue = any(equals(false), values)
|
||||
? false // court-circuit
|
||||
: any(equals(null), values) ? null : true,
|
||||
missingVariables = nodeValue == null ? chain(collectNodeMissing, explanation) : []
|
||||
missingVariables = nodeValue == null ? map(collectNodeMissing, explanation) : []
|
||||
|
||||
return rewriteNode(node, nodeValue, explanation, missingVariables)
|
||||
}
|
||||
|
@ -356,7 +356,7 @@ export let mecanismNumericalSwitch = (recurse, k, v) => {
|
|||
choice = find(node => node.condValue, explanation),
|
||||
missingVariables = choice
|
||||
? choice.missingVariables
|
||||
: chain(collectNodeMissing, explanation)
|
||||
: map(collectNodeMissing, explanation)
|
||||
|
||||
return rewriteNode(node, nodeValue, explanation, missingVariables)
|
||||
}
|
||||
|
@ -444,14 +444,13 @@ let doInversion = (situationGate, parsedRules, v, dottedName) => {
|
|||
if (fx(1000) == null)
|
||||
return {
|
||||
nodeValue: null,
|
||||
inversionMissingVariables: collectNodeMissing(
|
||||
inversionMissingVariables:
|
||||
evaluateNode(
|
||||
{},
|
||||
n => (dottedName === n ? 1000 : situationGate(n)),
|
||||
parsedRules,
|
||||
fixedObjectiveRule
|
||||
)
|
||||
)
|
||||
).missingVariables
|
||||
}
|
||||
|
||||
let tolerancePercentage = 0.00001,
|
||||
|
|
|
@ -5,5 +5,3 @@ export let val = node => node && node.nodeValue
|
|||
export let undefOrTrue = val => val == undefined || val == true
|
||||
|
||||
export let anyNull = any(pipe(val, equals(null)))
|
||||
|
||||
export let applyOrEmpty = func => v => (v ? func(v) : [])
|
||||
|
|
Loading…
Reference in New Issue