Skip to content

Commit

Permalink
Meal history working now. Added some debugging.
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard-Kirby committed Mar 5, 2023
1 parent c258e75 commit 0f0fa1f
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 6 deletions.
Binary file modified body_weight_history.db
Binary file not shown.
Binary file modified calorie_history_graph.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified calories_spent.db
Binary file not shown.
Binary file modified food_data.db
Binary file not shown.
Binary file modified history.db
Binary file not shown.
Binary file modified meal_history.db
Binary file not shown.
Binary file removed meal_history.db-journal
Binary file not shown.
16 changes: 10 additions & 6 deletions scale_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

# create logger
logger = logging.getLogger('scaleLogger')
logger.setLevel(logging.DEBUG)

import cProfile

Expand Down Expand Up @@ -696,6 +697,7 @@ def add_to_history(self):
print(fooddata_db_id, foodcode, foodname, weight, calories)

if fooddata_db_id !=0:
logger.debug(f"Food data being gathered for {fooddata_db_id}")
part_data = self.food_data_db_con.execute(
"SELECT id, FoodCode, FoodName, PROT, FAT, CHO, CHOL, TOTSUG, AOACFIB FROM FoodData WHERE id = ?",
(fooddata_db_id,))
Expand Down Expand Up @@ -739,12 +741,14 @@ def add_to_history(self):
logger.info(f'Meal History Add -->weight {weight}g protein {tot_protein}g, fat {tot_fat}g, '
f'carbs {tot_cho}g, chol {tot_chol}g, sugar {tot_sug}g, aoacfib {tot_aoacfib}')

self.meal_history_db_con.execute('INSERT INTO MealHistory (unix_ms, Date, fooddata_db_id, FoodName, '
'PROT, FAT, CHO, CHOL, TOTSUG, AOACFIB, KCALS, WEIGHT) '
'values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
[now_micro, now, fooddata_db_id, foodname,
tot_protein, tot_fat, tot_cho, tot_chol,
tot_sug, tot_aoacfib, calories, weight])
ret = self.meal_history_db_con.execute('INSERT INTO MealHistory (unix_ms, Date, fooddata_db_id, FoodName,'
'PROT, FAT, CHO, CHOL, TOTSUG, AOACFIB, KCALS, WEIGHT) '
' values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
[now_micro, now, fooddata_db_id, foodname,
tot_protein, tot_fat, tot_cho, tot_chol,
tot_sug, tot_aoacfib, calories, weight])
logger.info(f'sql return {ret}')
self.meal_history_db_con.commit()

if self.meal_total_calories != 0:
with self.history_db_con:
Expand Down
Binary file modified weight_history_graph.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0f0fa1f

Please sign in to comment.