spruhaN / nutrition_pal

1 stars 1 forks source link

Code Review (Asa Grote) #13

Open AsaGrote opened 1 month ago

AsaGrote commented 1 month ago

Suggestions for improvements:

  1. Break endpoints up into different files so your design is modular. Create files for user, goals, workout, etc.

  2. In main.py in /workout/{customer_id}, on line 62, use .scalar_one() rather than .first(). As Professor Pierce explained in lecture, this will result in safer code since we can only grab a single value from the query. Then, rather than using res.id, simply use res.

  3. It is unclear what units you are using for height and weight. That should be clear in your documentation and your code.

  4. Meal is very bare bones. I would suggest allowing users to add more information about meals they are consuming, such as food group, etc.

  5. It appears that the /daily_calories/{customer_id} endpoint simply uses the first goal that was created by the user. For example, I ran Flow #1: Tracking daily calories and inputting workouts. I created a goal with a daily calorie intake of 2000, then had two meals totaling 2000 calories. I then created a new goal with a daily calorie intake of 5000. The /daily_calories/{customer_id} endpoint still returned that calories_left was 0, despite my updated goal. One solution to this would be to order the SQL query by date created (descending) and select the first goal.

  6. In main.py, endpoints /workouts/{customer_id}/day on line 73 and /workouts/muscle_groups/{type} on line 95 both point to a function named "getWorkoutsByDay". Rename the getWorkoutsByDay function on line 96.

  7. Endpoint /workout/{customer_id} causes an internal server error.