Open Blackoverflow opened 2 years ago
Hi Blackoverflow, thank you for your feedback. I will improve this in future releases
I think it is realy a bug, some items add kcal some kj. I have investigated the openfood api and we can filter out the kcal numbers to compute right. I think it musst be here :
qml/components/IsProductFoundDialog.qml
{
var _json = openFoodFactJSON.model.get(0);
if (typeof _json !== "undefined" && typeof _json.product_name !== "undefined" ) {
logical_fields.ingestion.product_name = _json.product_name
logical_fields.ingestion.nutriscore = (typeof _json.nutriscore_grade == "undefined") ? "a" : _json.nutriscore_grade
logical_fields.ingestion.cal = (typeof _json.nutriments.energy_value == "undefined") ? 0 : _json.nutriments.energy_value
logical_fields.ingestion.fat = (typeof _json.nutriments.fat_100g == "undefined") ? 0.0 : _json.nutriments.fat_100g
logical_fields.ingestion.protein = (typeof _json.nutriments.proteins_100g == "undefined") ? 0.0 : _json.nutriments.proteins_100g
logical_fields.ingestion.carbo = (typeof _json.nutriments.carbohydrates_100g == "undefined") ? 0.0 : _json.nutriments.carbohydrates_100g
logical_fields.ingestion.nova_groups = (typeof _json.nova_groups == "undefined") ? "0" : _json.nova_groups
next_button.enabled = true
loading_circle.running = false
loading_circle.visible = false
}else{
loading_circle.running = false
loading_circle.visible = false
enter_manually.visible = true
is_code_empty = true
}
}
}
the _json.nutriments.energy_value
to not contain kcal consistently so we can use energy-kcal , energy-kcal_100g that holds the needed kcal value. but i do not know right now how to extract it from _json.nutriments.
The recommended calories seem to be calculated in kcal but the calories given for a scanned foot item (Fritz-Kola EAN 4260107220015) seem to be in kJ.
How it is:
What I wish for: