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

Add ability to set goals with effective from date #530

Merged
merged 2 commits into from
Mar 26, 2022

Conversation

EmilJunker
Copy link
Contributor

This PR adds the ability to set new nutrition goals without overwriting your previous goals (closes #519).

To do this, I completely reworked the way nutrition goals are stored by the app. Instead of

"goals": {
  "calories": ["2000", "", "", "", "", "", ""],
  "calories-shared-goal": true,
  "calories-show-in-diary": true,
  "calories-show-in-stats": true,
  ...
},

you can now have a whole list of goals per nutrient:

"goals": {
  "calories": {
    "show-in-diary": true,
    "show-in-stats": true,
    "goal-list": [{
        "shared-goal": true,
        "goal": ["2000", "", "", "", "", "", ""]
      },
      {
        "effectiveFrom": "2022-03-26T00:00:00.000Z",
        "shared-goal": true,
        "auto-adjust": true,
        "goal": ["2200", "", "", "", "", "", ""]
    }]
  },
  ...
},

The goals in the list may have an effectiveFrom date that is used to determine which goal should be used on a given day.

@davidhealey
Copy link
Owner

My only suggestion would be to change effectiveFrom to effective-from to maintain consistency with the other object keys. Although I prefer camel case so I have no idea why I went the - route to begin with (perhaps I was copying something else) :)

@EmilJunker
Copy link
Contributor Author

change effectiveFrom to effective-from

Oh, I didn't even notice. Sure, I can do that.

@EmilJunker
Copy link
Contributor Author

change effectiveFrom to effective-from

Done

@davidhealey davidhealey merged commit cb41083 into davidhealey:master Mar 26, 2022
@EmilJunker EmilJunker deleted the goals-by-date branch March 26, 2022 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Slight changes in average goal lead to jumps
2 participants