davidhealey / waistline

Libre calorie counter app for Android. Built with Cordova.
568 stars 67 forks source link

improve adjustment of servings/units in diary #84

Closed corngood closed 5 years ago

corngood commented 6 years ago

I usually just measure servings by mass, so for a bowl of cereal I'd put the bowl on the scale, zero it, add cereal, zero it, add milk, and record the mass of cereal and milk.

Having an amount field as well as servings on the 'edit entry' page, and having them update each other would be really useful for this. Then I would just add 'shreddies - 75g', and set the mass to e.g. 110g. Doing it with the servings field is ok if everything is in nice round numbers, but the info on packaging and OFF isn't always like that (at least here in Canada).

Even better would be some sort of slider/jog wheel control to make quick adjustments instead of having to use the keyboard.

I'm happy to put some time into making a PR if you think any of this would be useful.

davidhealey commented 6 years ago

You can put decimal numbers in the servings field, it doesn't have to be a whole number. I think all the nutritional info will be rounded though.

Have you tried using the recipe feature? This is what I use for my bowl of cereal which I do in the same way as you.

corngood commented 6 years ago

I spent a couple of days using recipes, and they are really useful for certain types of meals.

In a recipe when you add an item, you can just click on it and adjust the mass/volume, which is great. I still think it would be useful to be able to do that for items in the diary, instead of just the serving size scalar.

Another way to get the same result is to add items via a temporary recipe. I've done this, and it works, but I found that I had to actually name and save the recipe, which is quite cumbersome.

davidhealey commented 6 years ago

What about the quick-add feature? Is that any closer to what you're after?

corngood commented 6 years ago

You mean quick-add for calories? I personally avoid that because I'm trying to track the full nutritional info, and I'm not inputting burned calories.

Cereal probably wasn't a good example (because I'll typically just fill up the same sized bowl), but say I have food items added for: '100g cooked rice', '100g cooked green beans'. I go to plate it up and measure with my scale 175g of rice and 75g of beans. Then I go back and get 50g more rice for seconds. I can enter it in the diary as 1.75, 0.75 and 0.5 servings, but if the serving size isn't a nice round number, I have to do some math in my head.

If I was entering the same amounts in a recipe I'd just be able to click on them and put in the mass: 175, 75, 50, and it would work even if my food item was '75g cooked green beans'. However next time I cook rice and beans I'm probably not going to take exactly the same portions, so saving it as a recipe doesn't really make sense.

davidhealey commented 6 years ago

Ah I start to see now what you mean. Well I don't think it will be too difficult to make the serving size editable in the diary, I'll look into this when I'm putting the next update together. So there will be an extra field with the weight/mass just like in the food list. I'll probably make it so it automatically adjusts the serving size.

So If you have 100g of rice in the food list, and you add that to your diary, you can change the mass to 200g and the number of servings will automatically change to 2 but the food list won't be affected.

I'll refine this more when I come to code it.

corngood commented 6 years ago

Yeah, that would be perfect.

davidhealey commented 5 years ago

I'm currently implementing this. I'm thinking maybe I should drop the serving size altogether as I can't see a need for it if we can edit the portion by unit. What do you think?

corngood commented 5 years ago

Do you mean 'number of servings' in a diary entry? It might be redundant to store it in the db, but I think it would be useful to adjust both by number or units? I gave an example of weighing before, but an example for serving size would be a slice of bread, one serving is e.g. 65g. In that case it's nice to be able to set it to 1,2,3 servings.

I think it might also be worth trying to unify diary entries and recipe entries. Both are basically the same thing, but they have very different methods for adjusting portions.

Lately I've been doing a lot of this when I'm serving a meal:

davidhealey commented 5 years ago

Well the recipe system as it currently stands is going to become the "meal" system, and I'm going to add a new recipe system. So I'll take your suggestions into account as I work on it.

With a slice of bread I would put it in the food list as portion 1 and unit slice. But I see what you mean, some people might prefer to use grams or some other unit. So I'll keep both.

corngood commented 5 years ago

Maybe it would be a good idea to create an issue to discuss the new meal system? I'd like to hear more about it.

I've been imagining a system where food items and recipes (called meals maybe?) are abstracted into a tree structure so a food item can either be a single item or a recipe (list of items).

Then you could add a recipe to the diary and it would show up as the sum of all the nutritional values, but you could also scale it by units/portions at that level. This would be useful to add a recipe for say, soup, based on the ingredients you use to make the soup, but still be easily scaled when you serve yourself a bowl.

Another benefit would be the ability to add a recipe to another recipe. This would be useful if you make recipes for things that are later used as ingredients in other recipes. Maybe a roast dinner or something?

Also, when you add something to your diary you could search in a combined list of single food items and recipes, which might be a little faster.

Anyway, that's really off-topic, but if you do want to run any of your ideas by me, let me know.

Cheers

davidhealey commented 5 years ago

While I'm fiddling with this I've had a thought. Would it be better if instead of the diary being completely separate from the food list it instead references food list items directly. That way if you edit an entry in the food list it will update all instances in the diary. It will also mean I can add more stats to the food list without having to duplicate it in the diary.

This will be quite a radical change behind the scenes but shouldn't affect users at all since the diary already stores the foodID anyway (it just isn't used for anything yet but I thought all along it may come in handy).

corngood commented 5 years ago

I think it's a good idea to simplify things by having one record type with all the nutritional info, whether it's for a food item, diary entry, diary day, recipe, etc. That also makes it easier to share UI when editing those items.

However, I'm not sure about diary entries updating after the fact. I think that could have more negative consequences than positive. For example, if I change the quantity of a food item, or delete it entirely, would I expect my diary history to change? That's a tough one.

davidhealey commented 5 years ago

Ah yes that would be an issue. One option would be to hide deleted items instead of actually deleting them.

corngood commented 5 years ago

Yeah, you could even extend that to allow optionally modifying the history. If you don't want to affect existing diary entries and recipes, just hide the existing one and insert under a new ID. This would be similar to a calendar app dealing with recurring events. Could be overkill, I don't know.

I do think there's something to be said for the simplicity of using copies instead of references. I quite often add a recipe to the diary and then remove an item from it in the diary, or something like that.

I think I'll discuss this a bit more on #101, since it's probably more on-topic there.

davidhealey commented 5 years ago

Have the two lists does keep it simple. The only problem is if you make a mistake in your food list you have to then delete the item from the diary and re-add it once you've corrected the mistake.

davidhealey commented 5 years ago

Regarding the multiple lists vs single list thing I've decided to stick with multiple lists. It allows more flexibility.

Regarding editing mass. The next update will allow you to edit either the number of servings, the serving size, or both.