recipes icon indicating copy to clipboard operation
recipes copied to clipboard

Unit Conversion / Ingredient Property Calculation

Open vabene1111 opened this issue 1 year ago • 9 comments

wip on https://github.com/TandoorRecipes/recipes/tree/feature/unit-conversion

  • [x] recipe view nutrition UI
  • [x] page nutrition types
  • [x] page conversion
  • [x] conversion in food editor
  • [x] tests
  • [x] food editor merge/delete/..
  • [x] property calculation with empty unit/amount in food
  • [x] user choice for recipe vs food properties
  • [x] unit conversion editor fix?
  • [x] unit conversion in food editor?
  • [x] ~quick fda import in food editor?~
  • [ ] standard API tests
    • [x] food property
    • [x] property type
    • [x] unit conversion
    • [ ] recipe properties on recipe api view
  • [ ] formula based value calculation (possible only as template logic) https://github.com/TandoorRecipes/recipes/issues/896#issuecomment-1021380215
  • [ ] display logic for different property types (allergens red/green markers, price ranges)
  • [x] re-add open data import flow
  • [x] automatically load data from API (see #1773 #327 )
  • [x] add nutrition when importing recipes ##1270
  • [x] fixe unit conversion edit modal not showing food
  • [x] migration for existing nutrition data
  • [x] fix open data importer property recognition (probably helper field needed on property)

Notes

US/UK weight https://github.com/hgrecco/pint/blob/master/pint/default_en.txt#L588

US liquid volume https://github.com/hgrecco/pint/blob/master/pint/default_en.txt#L566 US other volume https://github.com/hgrecco/pint/blob/master/pint/default_en.txt#L577 (probably best to only include cup?)

UK Imperial Volumes https://github.com/hgrecco/pint/blob/master/pint/default_en.txt#L635

rest of the world weight: g, kg rest of the world volume: ml, (cl), (dl), l (only convert to ml/l but convert from others)

Food Nutrition APIS

  • https://fdc.nal.usda.gov/fdc-app.html#/?query=Potato
  • https://world.openfoodfacts.org/

vabene1111 avatar Mar 15 '23 14:03 vabene1111

The openfoodfacts database seems to be the best source for international nutritional values

https://wiki.openfoodfacts.org/API/Read/Search

current problem: searching the database returns very fuzzy results which often means people have to read trough hundres if not thousands of results to find a usable product.

Need to find a way to filter results better so less products not relevant to the search are returned.

-> main search endpoint does not allow to search for only product_name -> ingredient/category endpoints do not allow any filters at all

Maybe script to build own product name database ?

vabene1111 avatar Apr 15 '23 12:04 vabene1111

Perhaps offer an ability to use 'free' developer API key's of Edamam Food Database API

To enable the feature (or perhaps, as a requirement) - each user will need to supply their own API key for this website.

Here is a screenshot of the feature from the API's 'demo' page:

image

jeffward01 avatar May 14 '23 04:05 jeffward01

very interesting API, we are currently working on a tandoor specifc database but maybe the edamam API can help there too.

vabene1111 avatar May 17 '23 11:05 vabene1111

I'm not sure if this is the right place for a feature request concerning ingredient calculation, but it would be really nice if we could sort the ingredients, as sources are often consistently ordered a certain way.

Also, I've started testing this feature out and so far it works wonders. I do wonder however how much chance there is of feature related data loss, as it does determine how much effort I (and probably others) can afford testing it out.

Again, I'm loving the feature so far, and can't wait to see what its potential is.

DanielVoogsgerd avatar Jul 08 '23 18:07 DanielVoogsgerd

I'm not sure if this is the right place for a feature request concerning ingredient calculation, but it would be really nice if we could sort the ingredients, as sources are often consistently ordered a certain way.

Also, I've started testing this feature out and so far it works wonders. I do wonder however how much chance there is of feature related data loss, as it does determine how much effort I (and probably others) can afford testing it out.

Again, I'm loving the feature so far, and can't wait to see what its potential is.

I don’t understand your request. Ingredients are already ordered.

smilerz avatar Jul 08 '23 18:07 smilerz

Ah, sorry, I mistakenly wrote ingredients instead of ingredient properties.

Maybe I'm overlooking something, but as far as I know, ingredient properties don't have a way to be ordered in a user-defined way. I think the properties are sorted by default on their primary key id, so basically in order of creation. However, nutrient information in my country is almost always ordered in a specific way. So I have to remove the default fields and create them in the right order.

DanielVoogsgerd avatar Jul 09 '23 07:07 DanielVoogsgerd

Yes that's something I want to do, also wanted to allow some markup about how different things are rendered.but good idea with the order.

Regarding data loss: although the feature is considered beta /new I don't expect to do anything that would break existing data.

vabene1111 avatar Jul 09 '23 07:07 vabene1111

I am interested in helping out with the allergen feature. I think a property could be used, but then maybe a boolean type. Possible it needs a rule to determine how to combine values. Should all be true, or any? Something like that. I am looking to add allergy information to the recipes, then obviously it would be an "any" rule. Maybe we could predefine some well known allergies, and use the correct icons for those as well.

wligtenberg avatar Feb 11 '24 15:02 wligtenberg

Feel free to spin up a concept, probably best in a seperate issue and we can discuss how it could be done.

vabene1111 avatar Feb 11 '24 22:02 vabene1111