Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

decimals in properties issue #2518

Closed
vabene1111 opened this issue Jun 26, 2023 · 21 comments
Closed

decimals in properties issue #2518

vabene1111 opened this issue Jun 26, 2023 · 21 comments
Labels
bug Something isn't working

Comments

@vabene1111
Copy link
Collaborator

from @dsm1212

I realized you are still working on this so not submitting an issue, but the few things I tried to enter as a food just won't take. Here's a simple one. Baking powder at 1tsp (or 4.6g) has 1.3g of carbs. I tried to enter this multiple ways and none will work correctly. 4.6g/1.3g is an error saving. 1tsp/1.3g won't save correctly, it says success but ends up saving 1g/1.3g and with that impossible combo for 1tsp in recipe it show 0.05g of carbs which is odd. 46g/13g will save but the carb calculation for 1tsp in a recipe is 0. Probably I'm not doing the right thing with units.

opening a new issue as it has nothing to do with the other thread where this was posted

@vabene1111 vabene1111 added the bug Something isn't working label Jun 26, 2023
@vabene1111
Copy link
Collaborator Author

can confirm this is buggy

first of all food amounts did not support decimals, i added that but there is something else broken, looking into what it is

@vabene1111
Copy link
Collaborator Author

fixed the other issue as well

@dsm1212
Copy link

dsm1212 commented Jun 29, 2023

Thanks, is better but i'm still easily getting incorrect results. Couple of examples:

  1. I set all purpose flour to 120g having 16g protein and 92g carb. I had to use 120g because I could not get 1cup to save. It seems like once you save the unit on that field it cannot be changed?
  2. I added conversion of 120g to 1cup.

In a recipe which calls for 1.5 cups of all-purpose flour I get the correct totals for carbs and protein.
In a recipe for 1.25 cups of all-purpose flour I get zeros.
In a recipe for 2 cups of all-purpose flour I get zeros.
In a recipe for 2.5 cups of all-purpose flour I get zeros.

In all cases I'm drilling to the recipe by selecting "16 recipes" under all-purpose flour.

@vabene1111
Copy link
Collaborator Author

ok thanks, i need to look into that, reopening for now

@vabene1111 vabene1111 reopened this Jun 29, 2023
@vabene1111
Copy link
Collaborator Author

i think all of this might be releated to a bug in the frontend. I wasn't abel to fully test this as i need to leave my desk now but i pushed the fix on beta (which is currently pretty stable).

The problem was that the food editor would always show gram as i had a small piece of code setting the frontend to "g" regardless of what it actually was. so you probably had cups set but it was showing grams. I did it to set the default unit to g but forgot to check if anythign else was already present.

If you want you can try out if the issue is fixed, if not i will when i get the time to do so

@dsm1212
Copy link

dsm1212 commented Aug 1, 2023

Sorry, I never switched to beta. I'm not seeing any difference on mainline (yet).

@dsm1212
Copy link

dsm1212 commented Aug 1, 2023

Ah, I take that back, it is better. What I'm seeing now is that some recipes I used the word cups when it was > 1 cup and my conversion is for cup. I added an identical conversion for cups and now it works. This is fine, but I mention only because you might want to add volume equalities globally. Then you could automatically include plurals as well as common things like 3tsp == 1Tbl so we don't have to add them everywhere.

Is it possible to manually add another property? Sodium, Potassium in particular. These have an impact on kidneys and some people count them, if I'm going to enter this stuff I'd like to enter these as well.

Thanks!

@vabene1111
Copy link
Collaborator Author

if you have plurals or not depends on what units you created. if you created cup and cups seperately you will need to add your own conversions, but you can also add cup with plural cups and only need one.

regarding properties: you can add as many properties as you like on the property type page

@dsm1212
Copy link

dsm1212 commented Aug 5, 2023

Sorry I poked around and I can't figure out what this means: "you can also add cup with plural cups and only need one". Are you just saying use the plural all the time or is there a feature to somehow add cup along with cups and it will treat like one unit? I don't see many options on the unit editor. Just "name, description and Open Data Slug". Is open data slug some way to extend to plurals? thx

@vabene1111
Copy link
Collaborator Author

image

it should look like this with plural on the second line. Add "cup" as name "cups" as plural. Maybe i could add cup as a base unit as well but i think its a bit disputed how large a cup actually is

@dsm1212
Copy link

dsm1212 commented Aug 5, 2023

Wierd that is not what I see. I only have name, description, and open data slug. Maybe I should switch to beta?

@langbein-daniel
Copy link

Wierd that is not what I see. I only have name, description, and open data slug. Maybe I should switch to beta?

I'm not on beta (version 1.5.4) and I can enter plural names of ingredients. Can you double check the version you are running on @dsm1212? You can view it in Tandoor through the System menu entry.

@dsm1212
Copy link

dsm1212 commented Aug 5, 2023

Current Version: [1.5.4]

Here is my edit unit window:

image

@dsm1212
Copy link

dsm1212 commented Aug 5, 2023

Oh, wait, I'm choosing + from the units window. Are we talking about the Ingredients window? I have not used that yet. Foods seems to list all my ingredients so I'm not sure what the ingredients window does :-(. It has nothing in the list there right now.

@dsm1212
Copy link

dsm1212 commented Aug 5, 2023

Ok even though I'm not 100% sure what this window does, I got it to work. If I add the plural and then merge the plural to the singular it ends up in the right place. Very nice, thanks!

@vabene1111
Copy link
Collaborator Author

That is super strange, there used to be a setting of plurals should show or not but that was removed a few versions ago. Need to look into the code to see why this happens

@vabene1111
Copy link
Collaborator Author

ok so i looked at the code, i cannot find any condition that would hide the plural field. There was one in old versions so i suspect there could be a caching thing if you are on the latest version.

Can you check that you have the latest version installed and maybe clear the browser cache? this way there should not be any units left where you cannot edit the plural.

@dsm1212
Copy link

dsm1212 commented Aug 7, 2023 via email

@vabene1111
Copy link
Collaborator Author

yea I saw your message but was unsure what it meant. Need to look again but both windows should call the same function 🤔

@dsm1212
Copy link

dsm1212 commented May 24, 2024

FWIW to this day I still don't see plurals on the edit window from the unit list. I can only get at them from selecting the unit in the ingredient window and chosing edit. The other odd thing is after editting a plural from the ingredient window if I choose a different unit the list of recipes updates correctly but if I then pick edit on the new unit no windnow comes up. I have to refresh the tab to edit a second unit from the ingredient window.

@dsm1212
Copy link

dsm1212 commented May 25, 2024

Upgraded to latest and I can edit plurals in the units page :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants