Skip to content

Commit

Permalink
wip nutprogbar stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
gamesguru committed Feb 22, 2024
1 parent 9569a7c commit eedf676
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions ntclient/services/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
from ntclient.utils import CLI_CONFIG


################################################################################
##############################################################################
# Foods
################################################################################
##############################################################################
def foods_analyze(food_ids: set, grams: float = 0) -> tuple:
"""
Analyze a list of food_ids against stock RDA values
Expand All @@ -45,9 +45,9 @@ def print_header(header: str) -> None:
print()
print("=========================")

################################################################################
##########################################################################
# Get analysis
################################################################################
##########################################################################
raw_analyses = sql_analyze_foods(food_ids)
analyses = {}
for analysis in raw_analyses:
Expand All @@ -67,9 +67,9 @@ def print_header(header: str) -> None:
nutrients = sql_nutrients_overview()
rdas = {x[0]: x[1] for x in nutrients.values()}

################################################################################
##########################################################################
# Food-by-food analysis (w/ servings)
################################################################################
##########################################################################
servings_rows = []
nutrients_rows = []
for food_id, nut_val_tuples in analyses.items():
Expand All @@ -81,9 +81,9 @@ def print_header(header: str) -> None:
)
print_header("SERVINGS")

################################################################################
######################################################################
# Serving table
################################################################################
######################################################################
headers = ["msre_id", "msre_desc", "grams"]
serving_rows = [(x[1], x[2], x[3]) for x in serving if x[0] == food_id]
# Print table
Expand All @@ -101,12 +101,14 @@ def print_header(header: str) -> None:

print_header("NUTRITION")

################################################################################
# Nutrient tree-view
################################################################################
######################################################################
# Nutrient colored RDA tree-view
######################################################################
headers = ["id", "nutrient", "rda", "amount", "units"]
nutrient_rows = []
for nutrient_id, amount in nut_val_tuples:
# TODO: skip small values (<1% RDA), report as color bar if RDA is available

# Skip zero values
if not amount:
continue
Expand Down

0 comments on commit eedf676

Please sign in to comment.