def sub_menu_3(user_id): helper.print_menu(texts.sub_menu_3, "History", response = 0) helper.press_any_key() db.fetch_nutrient(user_id = user_id, nutrients = ['ndbno','name'],limit = 15, printing = True) while True: ndbno = helper.press_any_key(texts.sub_menu_3_line_1, inp = True) if ndbno == 'back': return if ndbno == 'logs': db.fetch_nutrient(user_id = user_id, nutrients = ['ndbno','name'],limit = 15, printing = True) elif ndbno == 'exit': close(user_id) else: try: food = Food(ndbno) db.log_food(food.data, user_id) except: error(ndbno)
def analyze_foods_sugars_index(user_id): indexes = db.fetch_nutrient(user_id, nutrients = ['Index',d['Sugars']]) render.bar_graph(indexes, name = "Health Index over Time")
def analyze_foods_protein(user_id): proteins = db.fetch_nutrient(user_id, nutrients = [d['Protein']]) render.bar_graph(proteins, name = "Protein Graph over Time")
def analyze_foods_sugar(user_id): sugars = db.fetch_nutrient(user_id, nutrients = [d['Sugars']]) render.bar_graph(sugars, name = "Sugar Graph over Time")
def main(): helper.print_with_line(texts.welcome) user_name = log_in() user_id = db.get_user_id(user_name) while True: helper.print_with_line(texts.menu, ref=True, n=0, title="Main menu") answer = helper.press_any_key(s="Enter your choice\n> ", inp=True) try: if answer == '1': data = interractive_get_index() print(data) elif answer == '2': db.fetch_nutrient(user_id=user_id, nutrients=['ndbno', 'name'], limit=15, printing=True) print("here is your most recent 15 entrees") ndbno = input( "Enter food's NDBNO if you know or look it up in main menu:\n> " ) data = fetch_nutrition(ndbno) db.log_food(data, user_id) elif answer == '3': helper.print_with_line(texts.vizualization_3, ref=True, n=30, title="Vizualization") sub_choice = helper.press_any_key(s="Enter your choice > ", inp=True) if sub_choice == '1': indexes = db.fetch_nutrient(user_id, nutrients=['269']) render.bar_graph(indexes, name="Health Index over Time") elif sub_choice == '2': sugar = db.fetch_nutrient(user_id, nutrients=['Index']) render.bar_graph(sugar, name="Sugar Graph over Time") elif sub_choice == '3': data = db.fetch_nutrient(user_id, nutrients=['269', 'Index']) print(data) render.bar_graph(data) elif answer == 'exit': helper.simple_print(texts.bye) break else: print("error #3") helper.print_with_line(texts.error.format(answer), ref=False) helper.pause(3) except Exception as err: exc_info = sys.exc_info() traceback.print_exception(*exc_info) del exc_info print(err) print("error #4") helper.print_with_line(texts.fatal_error, ref=False) helper.pause(3) continue