🐛 Résolution de la lenteur

AnalyseSituation était appelé à chaque action
pull/6/head
Mael Thomas 2017-03-27 15:02:50 +02:00
parent 0b412dac6d
commit b8359f02e7
4 changed files with 17 additions and 16 deletions

View File

@ -19,10 +19,10 @@ export default () => (
<p>
Ce simulateur calcule pour vous les 4 éléments de ce surcoût :
<ul>
<li>l'indemnité de fin de contrat</li>
<li>le CIF</li>
<li>la majoration chômage</li>
<li>l'indemnité compensatrice de congés payés</li>
<li key="1">l'indemnité de fin de contrat</li>
<li key="2">le CIF</li>
<li key="3">la majoration chômage</li>
<li key="4">l'indemnité compensatrice de congés payés</li>
</ul>
</p>
<p>Par simplification, ces éléments sont tous calculés par mois de contrat.</p>

View File

@ -1,12 +1,10 @@
import React, { Component } from 'react'
// import {findRuleByName} from '../engine/rules.js'
import {analyseSituation} from '../engine/traverse'
import './Rule.css'
import JSONTree from 'react-json-tree'
import R from 'ramda'
import PageTypeIcon from './PageTypeIcon'
import {connect} from 'react-redux'
import {formValueSelector} from 'redux-form'
import mockSituation from '../engine/mockSituation.yaml'
import {START_CONVERSATION} from '../actions'
import classNames from 'classnames'

View File

@ -78,6 +78,7 @@ let fillVariableNode = (rule, situationGate) => (parseResult) => {
category: 'variable',
fragments: fragments,
variableName,
name: variableName,
type: 'boolean | numeric',
explanation: parsedRule,
missingVariables: (variableIsRule || known) ? [] : [variableName],
@ -90,7 +91,6 @@ let fillVariableNode = (rule, situationGate) => (parseResult) => {
}
let treat = (situationGate, rule) => rawNode => {
// console.log('rawNode', rawNode)
let reTreat = treat(situationGate, rule)
if (R.is(String)(rawNode)) {
@ -253,7 +253,7 @@ let treat = (situationGate, rule) => rawNode => {
value={result.nodeValue}
child={
<ul>
{result.explanation.map(item => <li>{item.jsx}</li>)}
{result.explanation.map(item => <li key={item.name}>{item.jsx}</li>)}
</ul>
}
/>
@ -353,7 +353,7 @@ let treat = (situationGate, rule) => rawNode => {
value={node.nodeValue}
child={
<ul>
{node.explanation.map(item => <li>{item.jsx}</li>)}
{node.explanation.map(item => <li key={item.name}>{item.jsx}</li>)}
</ul>
}
/>
@ -450,17 +450,17 @@ let treat = (situationGate, rule) => rawNode => {
value={nodeValue}
child={
<ul>
<li>
<li key="base">
<span className="key">assiette: </span>
<span className="value">{base.jsx}</span>
</li>
{rate.nodeValue != 1 &&
<li>
<li key="rate">
<span className="key">taux: </span>
<span className="value">{rate.jsx}</span>
</li>}
{facteur.nodeValue != 1 &&
<li>
<li key="factor">
<span className="key">facteur: </span>
<span className="value">{facteur.jsx}</span>
</li>}
@ -490,7 +490,7 @@ let treat = (situationGate, rule) => rawNode => {
child={
<ul>
{contenders.map((item, i) =>
<li>
<li key={i}>
<div className="description">{v[i].description}</div>
{item.jsx}
</li>
@ -599,7 +599,8 @@ let treatRuleRoot = (situationGate, rule) => R.pipe(
- do they need variables that are not present in the user situation ?
- if not, do they have a computed value or are they non applicable ?
*/
export let analyseSituation = situationGate =>
export let analyseSituation = situationGate => console.log('analyseSituation' + Math.random()) ||
//TODO l'objectif devrait être spécifié par la page qui lance un simulateur
treatRuleRoot(
situationGate,

View File

@ -45,10 +45,14 @@ function pointedOutObjectives(state=[], {type, objectives}) {
let handleSteps = (state, action) => {
if (![START_CONVERSATION, STEP_ACTION].includes(action.type))
return state
let returnObject = {
...state,
analysedSituation: analyse(state)
}
if (action.type == START_CONVERSATION) {
return {
...returnObject,
@ -68,14 +72,12 @@ let handleSteps = (state, action) => {
R.splitWhen(stepFinder),
R.head
)(state.foldedSteps)
console.log('foldedSteps', foldedSteps)
return {
...returnObject,
foldedSteps,
unfoldedSteps: [R.find(stepFinder)(state.foldedSteps)]
}
}
return state
}
let analyse = R.pipe(