vkostyanetsky / ObsidianFoodiary

Food tracker plugin for Obsidian
https://kostyanetsky.me/notes/obsidian-foodiary/
MIT License
8 stars 0 forks source link

Feature Request: Add portion size to food #7

Open Cycor opened 5 months ago

Cycor commented 5 months ago

I know it's a big change but would it be possible to add the portion in the product, so we can use portions as a descriptor. Also including unit type would make it clearer to know what the portion size means. Products without portion could still be calculated the old way.

I would be a lot easier to just type:

Cheese 3 Eggs 1 Soup 200ml + 1 Donuts 85g

And the calories would then be per portion instead of 100g.

Cheese
---
calories: 103
fat: 8.5
portion: 28
unit: g
---

Soup
---
calories: 24
fat: 0.6
portion: 220
unit: ml
---

egg
----
calories: 72
fat: 4.8
potion: 50
unit: g
vkostyanetsky commented 5 months ago

Thanks for the ideas! I have a few questions to clarify.

  1. Is portion actually a multiplier for a value we set in a code block? For instance, Eggs 2 with portion: 50 and Eggs 100 without the portion property mean the same amount of calories & nutrients.

  2. It feels like the sole purpose of the unit property is to make the foodiary code block content a bit more readable. Consequently, the only thing we need to support this property is to ignore it while the plugin tries to understand how much a product weighs.

Am I right? For instance, Soup 200ml + 1 = Soup 200 + 1 = Soup 201.

Cycor commented 5 months ago

Yes you are right about the point 1, the portion would be the default amount if no unit is given, so 1 would be 50g if potion: 50 and unit: g

the unit part would be used to make it clear what the portion means and also so we can add it when we want to use our own size instead of a portion.

For point 2, in the example 200ml includes ml so we don't use the default portion, the result would become 200 / portion * calories/fat/etc, and the 1 doesn't have a unit so that would mean the default portion, so 220ml in my example.

So that would become 200 + 220