From 854ce8d2234a63214b50d1e9a21d512c019bc225 Mon Sep 17 00:00:00 2001 From: Johan Girod Date: Wed, 21 Apr 2021 10:55:58 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=A6=20Publicodes=20v1.0.0-beta.15?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modele-social/package.json | 4 ++-- mon-entreprise/package.json | 4 ++-- publicodes/CHANGELOG.md | 6 ++++++ publicodes/core/package.json | 2 +- publicodes/core/source/mecanisms/min.ts | 14 +++++++++++++- publicodes/core/test/mécanismes/le-minimum-de.yaml | 9 +++++++++ publicodes/example/publicode-react/package.json | 4 ++-- publicodes/ui-react/package.json | 4 ++-- 8 files changed, 37 insertions(+), 10 deletions(-) diff --git a/modele-social/package.json b/modele-social/package.json index 027cf1996..5c2e1eff4 100644 --- a/modele-social/package.json +++ b/modele-social/package.json @@ -16,11 +16,11 @@ "dist/index.js" ], "devDependencies": { - "publicodes": "^1.0.0-beta.14", + "publicodes": "^1.0.0-beta.15", "yaml": "^1.10.0" }, "peerDependencies": { - "publicodes": "^1.0.0-beta.14" + "publicodes": "^1.0.0-beta.15" }, "scripts": { "build": "node build.js", diff --git a/mon-entreprise/package.json b/mon-entreprise/package.json index fbf8ae165..fd753fed4 100644 --- a/mon-entreprise/package.json +++ b/mon-entreprise/package.json @@ -70,8 +70,8 @@ "fuse.js": "5.2.1", "iframe-resizer": "^4.1.1", "modele-social": "^0.2.0", - "publicodes": "^1.0.0-beta.14", - "publicodes-react": "^1.0.0-beta.14", + "publicodes": "^1.0.0-beta.15", + "publicodes-react": "^1.0.0-beta.15", "ramda": "^0.27.0", "react": "^17.0.0", "react-color": "^2.14.0", diff --git a/publicodes/CHANGELOG.md b/publicodes/CHANGELOG.md index ccf4de8dd..041cff1ab 100644 --- a/publicodes/CHANGELOG.md +++ b/publicodes/CHANGELOG.md @@ -19,3 +19,9 @@ - Corrige un bug bloquant qui empêchait l'utilisation de la bibliothèque - Enlève la dépendance à i18n et react-i18n et toute la traduction qui n'était pas utilisée de toute façon - Ajoute des tests et une publication automatique des paquets publicodes + +## 1.0.0-beta.15 + +**core** + +- Fix bug sur le mécanisme minimum, une valeur non applicable n'est plus considérée comme valant "0" (#1493) diff --git a/publicodes/core/package.json b/publicodes/core/package.json index 0f4429802..277b0d486 100644 --- a/publicodes/core/package.json +++ b/publicodes/core/package.json @@ -1,6 +1,6 @@ { "name": "publicodes", - "version": "1.0.0-beta.14", + "version": "1.0.0-beta.15", "description": "A declarative language for encoding public algorithm", "main": "dist/index.js", "types": "dist/types/index.d.ts", diff --git a/publicodes/core/source/mecanisms/min.ts b/publicodes/core/source/mecanisms/min.ts index 77b7d78fc..8964fad84 100644 --- a/publicodes/core/source/mecanisms/min.ts +++ b/publicodes/core/source/mecanisms/min.ts @@ -16,6 +16,18 @@ export const mecanismMin = (v, context) => { } as MinNode } -const evaluate = evaluateArray<'minimum'>((a, b) => Math.min(a, b), Infinity) +const min = (a, b) => { + if (a === false) { + return b + } + if (b === false) { + return a + } + if (a === null || b === null) { + return null + } + return Math.min(a, b) +} +const evaluate = evaluateArray<'minimum'>(min, false) registerEvaluationFunction('minimum', evaluate) diff --git a/publicodes/core/test/mécanismes/le-minimum-de.yaml b/publicodes/core/test/mécanismes/le-minimum-de.yaml index 4fda2a759..4da2bb301 100644 --- a/publicodes/core/test/mécanismes/le-minimum-de.yaml +++ b/publicodes/core/test/mécanismes/le-minimum-de.yaml @@ -28,5 +28,14 @@ Minimum avec variables: - situation: assiette: 1000 valeur attendue: 10 + +a: non +Minimum avec valeur non applicable: + formule: + le minimum de: + - a + - 10 + exemples: + - valeur attendue: 10 # TODO # Pouvoir faire référence à une variable, ou mettre une valeur. Aujourd'hui il est seulement possible de lister des mécanismes numériques diff --git a/publicodes/example/publicode-react/package.json b/publicodes/example/publicode-react/package.json index 2f70c62cc..e2b48009a 100644 --- a/publicodes/example/publicode-react/package.json +++ b/publicodes/example/publicode-react/package.json @@ -6,8 +6,8 @@ "@testing-library/jest-dom": "^5.11.4", "@testing-library/react": "^11.1.0", "@testing-library/user-event": "^12.1.10", - "publicodes": "../../core/publicodes-1.0.0-beta.14.tgz", - "publicodes-react": "../../ui-react/publicodes-react-1.0.0-beta.14.tgz", + "publicodes": "../../core/publicodes-1.0.0-beta.15.tgz", + "publicodes-react": "../../ui-react/publicodes-react-1.0.0-beta.15.tgz", "react": "^17.0.2", "react-dom": "^17.0.2", "react-router": "^5.2.0", diff --git a/publicodes/ui-react/package.json b/publicodes/ui-react/package.json index 8bbe11009..959b93613 100644 --- a/publicodes/ui-react/package.json +++ b/publicodes/ui-react/package.json @@ -1,6 +1,6 @@ { "name": "publicodes-react", - "version": "1.0.0-beta.14", + "version": "1.0.0-beta.15", "description": "UI to explore publicodes computations", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -26,7 +26,7 @@ "yaml": "^1.9.2" }, "peerDependencies": { - "publicodes": "1.0.0-beta.14", + "publicodes": "1.0.0-beta.15", "react": "^17.0.2", "react-router-dom": "^5.1.1", "react-router-hash-link": "^1.2.2"