diff --git a/src/assets/nutriments.json b/src/assets/nutriments.json index caa3995a0..46b2db1af 100644 --- a/src/assets/nutriments.json +++ b/src/assets/nutriments.json @@ -6,7 +6,6 @@ "unit": "kcal", "display": true }, - { "id": "energy", "name": "Energy", "unit": "kj" }, { "id": "energy-from-fat", "name": "Energy from fat", @@ -188,21 +187,6 @@ { "id": "caffeine", "name": "Caffeine", "unit": "mg" }, { "id": "taurine", "name": "Taurine", "unit": "g" }, { "id": "ph", "name": "PH", "unit": "" }, - { - "id": "fruits-vegetables-nuts", - "name": "Fruits‚ vegetables‚ nuts and rapeseed‚ walnut and olive oils", - "unit": "%" - }, - { - "id": "fruits-vegetables-nuts-dried", - "name": "Fruits‚ vegetables and nuts - dried", - "unit": "%" - }, - { - "id": "fruits-vegetables-nuts-estimate", - "name": "Fruits‚ vegetables‚ nuts and rapeseed‚ walnut and olive oils (manual estimate from ingredients list)", - "unit": "%" - }, { "id": "collagen-meat-protein-ratio", "name": "Collagen/Meat protein ratio (maximum)", @@ -210,18 +194,6 @@ }, { "id": "cocoa", "name": "Cocoa (minimum)", "unit": "%" }, { "id": "chlorophyl", "name": "Chlorophyl", "unit": "g" }, - { "id": "carbon-footprint", "name": "Carbon footprint", "unit": "g" }, - { - "id": "carbon-footprint-from-meat-or-fish", - "name": "Carbon footprint from meat or fish", - "unit": "g" - }, - { - "id": "nutrition-score-fr", - "name": "Nutrition score - France", - "unit": "" - }, - { "id": "nutrition-score-uk", "name": "Nutrition score - UK", "unit": "" }, { "id": "glycemic-index", "name": "Glycemic Index", "unit": "" }, { "id": "water-hardness", "name": "Water hardness", "unit": "mmol/l" }, { "id": "choline", "name": "Choline", "unit": "g" }, diff --git a/src/pages/nutrition/config.ts b/src/pages/nutrition/config.ts index eff1c0075..9360ba960 100644 --- a/src/pages/nutrition/config.ts +++ b/src/pages/nutrition/config.ts @@ -1,145 +1 @@ export const UNITS = ["", "g", "mg", "µg"]; - -export const KNOWN_NUTRIMENTS = [ - // Energy - "energy-kj", - "energy-kcal", - - // Fat - "fat", - "saturated-fat", - "unsaturated-fat", - "monounsaturated-fat", - "polyunsaturated-fat", - "trans-fat", - "butyric-acid", - "caproic-acid", - "caprylic-acid", - "capric-acid", - "lauric-acid", - "myristic-acid", - "palmitic-acid", - "stearic-acid", - "arachidic-acid", - "behenic-acid", - "lignoceric-acid", - "cerotic-acid", - "montanic-acid", - "melissic-acid", - - // Sucres - "carbohydrates", - "sugars", - "added-sugars", - "sucrose", - "glucose", - "fructose", - "lactose", - "maltose", - "maltodextrins", - - "fiber", - "soluble-fiber", - "insoluble-fiber", - - "proteins", - "casein", - "serum-proteins", - - "salt", - "added-salt", - "sodium", - - "cholesterol", - - "alpha-linolenic-acid", - "eicosapentaenoic-acid", - "docosahexaenoic-acid", - "omega-3-fat", - "omega-6-fat", - "linoleic-acid", - "arachidonic-acid", - "gamma-linolenic-acid", - "dihomo-gamma-linolenic-acid", - "omega-9-fat", - "oleic-acid", - "elaidic-acid", - "gondoic-acid", - "mead-acid", - "erucic-acid", - "nervonic-acid", - - "oligosaccharide", - - "galactose", - "starch", - "Polydextrose", - "polyols", - "erythritol", - - "nucleotides", - "alcohol", - "vitamin-a", - "beta-carotene", - "vitamin-d", - "vitamin-e", - "vitamin-k", - "vitamin-c", - "vitamin-b1", - "vitamin-b2", - "vitamin-pp", - "vitamin-b6", - "vitamin-b9", - "folates", - "vitamin-b12", - "biotin", - "pantothenic-acid", - "silica", - "bicarbonate", - "sulphate", - "nitrate", - "nydrogencarbonate", - "nitrite", - "potassium", - "chloride", - "calcium", - "phosphorus", - "iron", - "magnesium", - "zinc", - "copper", - "manganese", - "fluoride", - "selenium", - "chromium", - "molybdenum", - "iodine", - "caffeine", - "taurine", - "ph", - "collagen-meat-protein-ratio", - "cocoa", - "chlorophyl", - "glycemic-index", - "water-hardness", - "choline", - "phylloquinone", - "beta-glucan", - "inositol", - "carnitine", - "spermidine", - "water", - "acidity", - "dry-residue", - "beta-alanine", - "creatine", - "l-citrulline", - "l-glutamine", - "bcaa", - "l-valine", - "l-leucine", - "l-isoleucine", - "l-arginine", - "l-cysteine", - "l-Glutathione", -]; diff --git a/update-nutriments.js b/update-nutriments.js index 7dcd5b8dc..ba1bfa8ed 100644 --- a/update-nutriments.js +++ b/update-nutriments.js @@ -1,6 +1,16 @@ const fs = require("fs"); const axios = require("axios"); +const idsToIgnore = [ + "energy", + "fruits-vegetables-nuts", + "fruits-vegetables-nuts-dried", + "fruits-vegetables-nuts-estimate", + "carbon-footprint", + "carbon-footprint-from-meat-or-fish", + "nutrition-score-fr", + "nutrition-score-uk", +]; function parseNutrients(data, depth = 0) { return data.flatMap((item) => { const { display_in_edit_form, unit, id, name, nutrients } = item; @@ -31,7 +41,11 @@ axios("https://world.openfoodfacts.org/cgi/nutrients.pl") .then(({ data }) => { fs.writeFile( "./src/assets/nutriments.json", - JSON.stringify(parseNutrients(data.nutrients)), + JSON.stringify( + parseNutrients(data.nutrients).filter( + ({ id }) => !idsToIgnore.includes(id), + ), + ), () => console.log("nutriments updated"), ); })