wger
wger copied to clipboard
Macronutrient Calculator
This may be a simple, but helpful to people who are unfamiliar with dieting.
Macros are simply carbs, fat and protein.
Since dieting involves more than calorie intake alone, I think it would be helpful to create a section explaining what macros are and creating a calculator that calculates for the person how much of each macros they should be having per day in accordance to their goal.
I'd like to work on this aspect, however I am fairly new to open source, and coding in general.
Hi there!
This could be specially useful combined with the nutrition diary (which is not yet ready, but is almost finished), which logs what you actually ate, as oppossed to what the plan says you should. We could save a couple of presets which macro targets (which would need to be a bit dynamic, i.e. based on weight, age, etc.) to see how well the user is doing.
It's also great that you want to help! 👍 and don't worry, you don't need to know everything to contribute to open source. Have you worked with python/django before?
Hello! Yes, I have worked with Python before but to a very limited extent. I am in my first year of computer science at university, so I understand programming in a larger sense, and can pick up on things pretty quickly using examples or documentation.
Also, I've done some research on how to calculate macros, and I've got a pretty good idea of what would need to be calculated and saved.
Ah, cool, then you will be right at home :)
Then let's get started! What did you have in mind?
Hi!
So essentially, we would need to begin with BMR, which is already calculated. That value would need to be stored. While going through the code in the models.py file within users, where the code for the calculator functionality is, the method that is in there is a bit more involved than the one I had. So it might be a bit easier to write a separate code for certain things, and store just a few of the needed values.
The method I had in mind is fairly simple. I just did a quick search on how to find appropriate macronutrient values, and came up with the following.
Begin by calculating the BMR, which a calculator for already exists, so that would need to be stored.
In terms of Activity level, all I had in mind were: -Sedentary, which would multiply the BMR by 1.2x -Light Activity, BMR x 1.375 -Moderate Activity, BMR x 1.55 -Very Active, BMR x 1.725
From this, we obtain the Total Daily Energy Expenditure (TDEE).
Each of these activity levels have caloric values to them, I just left them out for now.
After this is calculated, we now have to decide weather the goal is to lose or gain, which is done by: To Gain- TDEE + (TDEE * .2) To Lose - TDEE - (TDEE * .2)
These multipliers are not concrete and we could change them if we want, with more research.
Up to this point, we are only calculating the loss/gain of weight, which involves muscle.
So now, we want to calculate macros, to allow for fat loss or lean gain.
Keep in mind the following values: 1g of Protein = 4 calories 1g of Carb = 4 calories 1g of Fat = 9 Calories
So in order to make Lean Mass Gains, the recommended values are: 40-60% carb 25-35% Protein 15-25% fat
For Fat Loss: 40-50% Protein 30-40% Fat 10-30% Carb
The range can exist as it is, and adjustable to the user. The idea is to allow freedom for each individual to find their sweet spot.
So as an example a 77kg male, very active, 6ft in height (182.88cm) and age 25, wanting to gain lean mass would be calculated this way:
BMR ~ 1793 TDEE = 1793 * 1.725 = 3092.925 Gain = TDEE + TDEE*.2 = 3711.51
Assuming 60% carb, 35% protein and 25% fat: 3711.51 * .60 = 2226.906 calories = 556.72 g Carbs 3711.51 * .35 = 1299.03 = 324.75 g Protein 3711.51 * .25 = 927.88 = 103.09 g Fat
The values are approximations. The percentages can be adjusted.
And thats all I've got.
Sorry for the long post! :- )
That sounds very sensible.
I'm not sure how much leeway we need for the different factors (e.g.the 0.2 multiplier for the TDEE), but I agree that these should be just a suggestion and the user should be able to edit all these values. We would also need to make this intuitive, since there are a lot of numbers, values, etc.
I think we could include a separate page with all the information regarding this since it is a fairly complex thing to understand. Other than that, the user will just have to enter the values we need and everything else will be calculated for them.
Considering this is okay, what steps should I take next?
Definitely, this should be on a different page. Would it be overkill to draw some mock ups? We also need to decide which new fields we need on the user profile, in any case we'll need carbs, fat, protein, tdee
I could draw up some mockups, no problem.
I think the most efficient thing to do would be to automatically calculate and store BMR when the user profile is created, after which calculating the TDEE would be fairly simple based on the user response.
After its calculated, then we can store the macros within the profile for later viewing.
So I created what I think could be what the page itself looks like. It's pretty rough, but in terms of what we REALLY need, I think that will be all, since all the other data will be stored using the BMI calculator.
Excuse my sub-par photoshopping :P

haha, don't worry, I wouldn't have done it better!
But yes, that's also what I had in mind. After answering the questions (gain/lose weight, etc.) we take those macros and show them next to the values from the current plan, till both are the same
It also seems we need to use d3js, the library we use to draw the diagrams, directly. I was using a library on top of it to make things sane, but that one is only for time based data series
So, as far as getting started with this, should I begin with writing the code for the calculator first?
Yeah, start with that
Pie chart with d3: https://bl.ocks.org/mbostock/3887235
Since this doesn't need to be fancy (animations, etc.) this is OK
I really really reallllllyyyyy like this.
Excuse me for my crappy english, but would it be able to 'add' some sort of Weight Watchers program points system for the people ? I have my own fitness gym and i'm using WGER for my customers to put in there foods, if I could use a points system like weights watchers, it could be a lot more fun for the people to learn them to work with calories, proteins, fats, carbs (with & without fiber)
Eg. http://www.wikihow.com/Calculate-Your-Weight-Watchers-Points
Here is an How-To with formula, this should be do-able to enable the point system in the wger program, and then it calculates the points automaticly when I (or a customer) puts in the values of an ingredient ?
First know how many points you get: Total Energy Expenditure formula is: TEE = 387 - (7.31 x age) + (PA x ((10.9 x wgt) + (660.7 x Ht))[1]
Eg. customer puts in proteins,fats,carbs & fiber .. Food ingredient gets 2 points..
Points Plus = (Protein grams / 11) + (Carbohydrate grams / 9) + (Fat grams / 4) - (Fiber grams / 35)
Also adding in that eg. every 30 mins of sport gives you an extra point to eat.
Making this simple:
Based on your sex, height & weight you get points .. The more you workout, the more you can eat points.
Based on the formula, every ingredient has it's own points.
This is just for people who have 0 knowledge of food & want to learn what's healty and what's not..
Also foods with a high base of value, is it possible to MARK those as "HEALTHY" ?
Last but not least.. A food scanner like Myfitnesspal .. is that even possible in WGER ?
@rolandgeider I noticed that this is from three years ago. How is the nurition diary doing now? Has this macronutrient calculator been implemented already?
Hi there!
This could be specially useful combined with the nutrition diary (which is not yet ready, but is almost finished), which logs what you actually ate, as oppossed to what the plan says you should. We could save a couple of presets which macro targets (which would need to be a bit dynamic, i.e. based on weight, age, etc.) to see how well the user is doing.
It's also great that you want to help! and don't worry, you don't need to know everything to contribute to open source. Have you worked with python/django before?
The nutrition diary is available, on the calculator side, no work has been done.