Skip to content

Commit

Permalink
Merge pull request #839 from datagir/opti-activation-from-master
Browse files Browse the repository at this point in the history
Feat: activation de l'optimisation du modèle avec publiopti follows incubateur-ademe/nosgestesclimat#1697
  • Loading branch information
EmileRolley authored Feb 27, 2023
2 parents 3d24573 + 4943454 commit dd456fa
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 29 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ The model YAML files will then be loaded locally (no installation needed, they a

> The production version fetches the JSON compiled YAML rules deployed by datagir/nosgestesclimat.
Then run this command in this repo :
Then run this command from this repo:

`yarn && yarn start`
```
yarn && yarn start
```

If you want to run the automatic localisation, which depdends on a Netlify Edge function, you must run `netlify dev`.
If you want to run the automatic localisation, which depends on a Netlify Edge function, you must run `netlify dev`.

## Réutilisations de ce code

Expand Down
10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@
},
"scripts": {
"prepare": "node scripts/prepare.js",
"start": "webpack serve --mode development --config webpack.dev.js & yarn run start:model",
"start:model": "yarn --cwd ./nosgestesclimat/ compile-watch & http-server ./nosgestesclimat/public/ -p 8081 --cors -c-1",
"model:watch": "yarn --cwd ./nosgestesclimat/ compile-watch",
"model:serve": "http-server ./nosgestesclimat/public/ -p 8081 --cors -c-1",
"serve":"webpack serve --mode development --config webpack.dev.js",
"start": "yarn run serve & yarn run model:watch & yarn run model:serve",
"compile": "NODE_ENV=production yarn run webpack --config webpack.prod.js",
"stats": "webpack --config webpack.prod.js --profile --json > stats.json",
"analyze-bundle": "ANALYZE_BUNDLE=1 yarn run build",
"clean": "rimraf dist node_modules source/data",
"test": "yarn test:file \"./{,!(node_modules)/**/}!(webpack).test.js\"",
"test:file": "yarn mocha-webpack --webpack-config ./webpack.dev.js --include test/componentTestSetup.js --require mock-local-storage --require test/helpers/browser.js",
"test:bundlesize": "bundlesize",
"test:dev-e2e:publicode": "cypress open --browser chromium --config baseUrl=http://localhost:8080/publicodes,integrationFolder=cypress/integration/publi.codes",
"generate:ui": "node scripts/i18n/generate-ui.js",
"translate:ui": "node scripts/i18n/translate-ui.js",
"translate:faq": "node scripts/i18n/translate-faq.js",
Expand Down Expand Up @@ -82,7 +81,6 @@
"postcss-loader": "^7.0.0",
"prettier": "^2.7.1",
"prettier-plugin-organize-imports": "^3.1.1",
"publiopti": "^0.1.21",
"raw-loader": "^4.0.2",
"style-loader": "^3.3.1",
"toml-loader": "^1.0.0",
Expand Down
5 changes: 3 additions & 2 deletions source/RulesProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,9 @@ export const WithEngine = ({
const currentRulesOptions = engineState?.options

useEffect(() => {
if (options?.optimized) console.log('🗜️ Optimized rules requested')
else console.log('💯 Complete rules requested')
options?.optimized
? console.log('🗜️ Optimized rules requested')
: console.log('💯 Complete rules requested')
if (
// This is a fixed point, no interest to go back to optimized at this point
engineState.state === 'ready' &&
Expand Down
2 changes: 1 addition & 1 deletion source/reducers/rootReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ export type RulesOptions = { optimized: Boolean; parsed: Boolean }

//TODO set to false by default in order to go to production. Forced until this error is fixed and tests are run
// https://github.com/EmileRolley/publiopti/issues/4
export const defaultRulesOptions = { optimized: false, parsed: true }
export const defaultRulesOptions = { optimized: true, parsed: true }

const defaultEngineState = { state: null, options: defaultRulesOptions }

Expand Down
10 changes: 5 additions & 5 deletions source/sites/publicodes/pages/QuickDocumentationPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ const Breadcrumb = ({ rules, dottedName }) => {
.reverse()
.map((parentDottedName) => {
const rule = rules[parentDottedName]
return (
return rule === undefined ? null : (
<span key={parentDottedName}>
{rules[parentDottedName].icônes && (
<span>{rules[parentDottedName].icônes}</span>
)}
{rule.icônes !== undefined && <span>{rule.icônes}</span>}
<Link to={utils.encodeRuleName(parentDottedName)}>
{title({ ...rule, dottedName: parentDottedName })}
</Link>
Expand All @@ -38,7 +36,9 @@ const Breadcrumb = ({ rules, dottedName }) => {
</span>
)
})
if (!elements.length) return null
if (!elements.length) {
return null
}
return <small>{elements}</small>
}

Expand Down
12 changes: 0 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1948,11 +1948,6 @@
resolved "https://registry.npmjs.org/@types/node/-/node-18.0.1.tgz"
integrity sha512-CmR8+Tsy95hhwtZBKJBs0/FFq4XX7sDZHlGGf+0q+BRZfMbOTkzkj0AFAuTyXbObDIoanaBBW0+KEW+m3N16Wg==

"@types/node@^18.11.18":
version "18.11.18"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.11.18.tgz#8dfb97f0da23c2293e554c5a50d61ef134d7697f"
integrity sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA==

"@types/parse-json@^4.0.0":
version "4.0.0"
resolved "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz"
Expand Down Expand Up @@ -7180,13 +7175,6 @@ publicodes@^1.0.0-beta.66:
resolved "https://registry.yarnpkg.com/publicodes/-/publicodes-1.0.0-beta.66.tgz#e8149733431268c764ea150dc82d3ce3709d20db"
integrity sha512-9lnLnbMM8Mz2+WvNK3/DttRbu6UvpoRx/B9XrMWUSgsb760uwQEqdpkHbl1gPlz2WpYSRuKZVyuW8LdfxTFRXw==

publiopti@^0.1.21:
version "0.1.21"
resolved "https://registry.yarnpkg.com/publiopti/-/publiopti-0.1.21.tgz#3c7d4fe6a4886abb1086317a5f7539964137ff28"
integrity sha512-VfGkT4v0sb0B4yr9EykBTsU8riTsLYWd2RUDgm6fIK8pEAL8JRof7ljwE8EsVyT7Z4vZDoSDBpZf5gRylfc3GQ==
dependencies:
"@types/node" "^18.11.18"

pump@^2.0.0:
version "2.0.1"
resolved "https://registry.npmjs.org/pump/-/pump-2.0.1.tgz"
Expand Down

0 comments on commit dd456fa

Please sign in to comment.