davidhealey / waistline

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

Carrying over calories to the next day #431

Closed h-h-h-h closed 2 years ago

h-h-h-h commented 2 years ago

In Waistline v2, I always did this with my generic "Calories" entry, defined as 1 kcal. Depending on whether I ate more or less calories in a day, I entered a positive or negative number as the portion count; then, for the next day I entered the negated value.

Now, having upgraded to Waisline v3, negative portion counts aren't allowed anymore. Fortunately, the app at least doesn't crash because of my past negative diary entries.

EmilJunker commented 2 years ago

Would a quick, temporary fix be possible to allow negative numbers if, e.g., the entry is defined as having 1 kcal?!

You are right that it is currently not possible to enter a negative portion size. However, negative calories values are allowed, so you could simply create another generic calories entry defined as -1 kcal and use that.

Alternatively, you could use the quick add feature by long-pressing the plus button in the diary. This also allows you to enter negative calorie values.

And then, would you please create a function to be able to carry over calories to the next day, no matter whether the daily goal is still green or it got red? I just want the average intake to adhere to my goal.

I don't understand your request. In the Goal editor, there already is an "auto adjust to meet weekly goal" option which carries over the difference in calories and distributes it evenly among the remaining days of the week. Is this not what you want?

h-h-h-h commented 2 years ago

You are right that it is currently not possible to enter a negative portion size. However, negative calories values are allowed, so you could simply create another generic calories entry defined as -1 kcal and use that.

Alternatively, you could use the quick add feature by long-pressing the plus button in the diary. This also allows you to enter negative calorie values.

That is very useful for my purpose. So, I can continue the way I was used to, for now.

In the Goal editor, there already is an "auto adjust to meet weekly goal" option which carries over the difference in calories and distributes it evenly among the remaining days of the week. Is this not what you want?

I'm not sure how this behaves exactly. When I activated it, the first thing it did was bringing the goals of the last few days, that I checked, out of their previous alignment with the logged calories (it was obviously all the same values). Is it confused by my negative diary entries?

...distributes it evenly among the remaining days of the week.

So, is the Sunday-Monday boundary special for this function (would be strange), or do you talk about the next(/last?) 6 or 7 days, starting from every day? It seems quite intransparent to me. I'm not sure how to utilize or trust this function.

EmilJunker commented 2 years ago

Is it confused by my negative diary entries?

Maybe. If you want to start using this feature, you can (and should) stop entering the negative calorie values manually.

So, is the Sunday-Monday boundary special for this function

Yes (or actually no, it's the Saturday-Sunday boundary that is special). The counter is reset every Sunday, so it might not be exactly what you want.

davidhealey commented 2 years ago

it's the Saturday-Sunday boundary that is special

Maybe a feature request to add a setting to choose first day of the week

h-h-h-h commented 2 years ago

The counter is reset every Sunday, so it might not be exactly what you want.

It really sounds like that. I don't see how a weekly reset would make sense for me. It's just one continuous stream of time for me.

A further possibility for simplifying carrying over calories would be the following:

A less user-friendly alternative would be:

EmilJunker commented 2 years ago

@h-h-h-h Please don't get me wrong, but I think your suggestions are a bit overly specific to your particular use case.

I understand your desire to have your average calorie intake adhere to your goal. And I agree that the current auto-adjust feature (which is reset every seven days) doesn't really help with that. However, there is a reason why the auto-adjust feature only takes the days of the current week into account. Let me try to explain:

If the auto-adjust feature is enabled, the app doesn't actually "carry over" the difference in calories, but it adjusts your goals in such a way that you meet your goal for the week (that is, the sum of your daily goals). For instance, if your daily goal is 2000 kcal, it adjusts your goals to ensure that your total intake at the end of the week is 14000 kcal. All these computations are performed "on the fly", so if you change the quantity of an item you ate yesterday, the goal for today (and the remaining days of the week) is adjusted automatically. Now you hopefully understand why it can only take the last few days into account. Anything more would be too computationally intensive.

That being said, I would absolutely like to support your use case as well. To do that, I am proposing the following solution that (hopefully) combines the best of both worlds:

I am going to add a setting to choose the first day of the week, i.e. the day when the auto-adjust counter should be reset. Once this is done, I was thinking to also add a (possibly hidden) setting that automatically pushes the first day of the week one day further every day. So if today is Tuesday, and Tuesday is currently your first day of the week, then the app automatically changes it to Wednesday. This way, the auto-adjust feature would always take the last seven days into account for its computations. While this does not 100% ensure that your average intake exactly matches your goal, I think it should be close enough.

What do you think of this proposal?

Also, could you tell me whether you have the "Same goal every day" option enabled? If yes, this would make the implementation a whole lot easier.

h-h-h-h commented 2 years ago

could you tell me whether you have the "Same goal every day" option enabled?

Yes, it's enabled.

a (possibly hidden) setting that automatically pushes the first day of the week one day further every day.

Sounds like a strange setting, but if it's the best implementation-wise. ¯\_(ツ)_/¯

I am going to add a setting to choose the first day of the week, i.e. the day when the auto-adjust counter should be reset.

This setting should then be communicated to be very specifically bound to the "Auto-adjust to meet weekly goal" setting.

But why make the additional setting hidden?


These options could even be presented a whole different way, while still implementing it the way you described:

You should know that I sometimes make entries for the following day, because of fluctuating sleeping times. You should generally take into account that shift workers use the app, leading to such usage. So the averaging feature shouldn't get confused by following-day entries. (But why shouldn't the app prohibit far-future entries to make its averaging behavior clearer?) If you can't do an 8-day, but only a 7-day average for implementation restrictions, this would seem to imply that the max setting for mode 2's setting would be 5 days back from today, reaching until tomorrow.


Do you really think this would be easier than a carry-over feature with a special line of text at the top that can be canceled and reinstated by tapping on it, auto-triggered by creating the first entry of the day? There also wouldn't be any bothering with something being to computationally intensive. And it would be guaranteed to be accurate without any possible drift. Internally, it could just create and end-of-day and start-of-day entry with different signs as I do manually now, flagged specially in the database, not displayed as normal entries, not accounted for in the spent-calories sum, and only the hidden start-of-day entry is accounted for in the goal for the day (according to my current spontaneous glance).

EmilJunker commented 2 years ago

This setting should then be communicated to be very specifically bound to the "Auto-adjust to meet weekly goal" setting. But why make the additional setting hidden?

I'm not sure yet what is the best way to implement this without confusing the user too much. We'll see...

Provide additional setting for day of reset, not a general, app-wide first-day-of-week setting.

Allowing each goal to have its own reset day would have a negative impact on performance. It is crucial that all goals are calculated in a single go.

You should know that I sometimes make entries for the following day

Entries on the following day should have no impact on the goal for the current day, though. Unless I'm misunderstanding something.

Do you really think this would be easier than a carry-over feature with a special line of text ...

Yes, my proposed solution is a lot easier. And it still calculates correctly even when you change a diary entry from a few days ago.

h-h-h-h commented 2 years ago

Provide additional setting for day of reset, not a general, app-wide first-day-of-week setting.

Allowing each goal to have its own reset day would have a negative impact on performance. It is crucial that all goals are calculated in a single go.

I wasn't proposing multiple reset-day settings, but still just one. I'd just advise against establishing a first-day-of-week setting that the user looks at to have a general, app-wide meaning, from the view of the user possibly associated with undiscovered features and in the future maybe in fact associated with additional features. Instead, the setting should, from the start, clearly be nothing else but the reset day of the auto-adjust feature.

I'm not sure yet what is the best way to implement this without confusing the user too much.

Presenting the reset-day setting via the 2 modes I described should not be confusing, while that technical "we'll use this setting to indirectly achieve that" would be rather confusing. The indirectness of the reset-day setting, when the user wishes to average the last few days, should be encapsulated by the app, not handled in the user's brain.

EmilJunker commented 2 years ago

the setting should, from the start, clearly be nothing else but the reset day of the auto-adjust feature.

The first day of the week setting will be more than just the reset day for the auto-adjust feature, though. It will also determine the order of the input fields in the goal editor. I think the best option would be to add a new settings category subpage called "Goals" and put this setting there.

Presenting the reset-day setting via the 2 modes I described

Yes, I think I'll add another setting to that subpage called "compute average goal based on" with options "current week" and "last seven days". And then I'll change "...weekly goal" to "...average goal" in the goal editor.

h-h-h-h commented 2 years ago

The first day of the week setting will be more than just the reset day for the auto-adjust feature, though. It will also determine the order of the input fields in the goal editor.

But if you plan to daily push the setting one day further whenever the last-few-days feature is enabled, this, too, would constantly fluctuate. Also, "average last 7 days" could be circumvented and effectively be made into, e.g., "average last 3 days" without any transparency about it. 😐

I think I'll add another setting to that subpage called "compute average goal based on" with options "current week" and "last seven days". And then I'll change "...weekly goal" to "...average goal" in the goal editor.

👍