remove biometrics, for now
authorShane Jaroch <chown_tee@proton.me>
Mon, 11 Jul 2022 15:29:03 +0000 (11:29 -0400)
committerShane Jaroch <chown_tee@proton.me>
Mon, 11 Jul 2022 15:29:03 +0000 (11:29 -0400)
README.rst
ntclient/argparser/__init__.py
ntclient/argparser/funcs.py
ntclient/ntsqlite
ntclient/persistence/sql/nt/funcs.py
ntclient/services/__init__.py
ntclient/services/biometrics.py [deleted file]
tests/test_cli.py

index 5139a21e7e8db2105294963bca0e9b1f72bf4806..6072726a0ef1b772682dae3ecf6975c97d6be073 100644 (file)
@@ -168,4 +168,3 @@ Commands
         anl                 analyze food(s)
         day                 analyze a DAY.csv file, RDAs optional
         recipe              list and analyze recipes
-        bio                 view, add, remove biometric logs
index 1e6267100ef330239326658c451aaaf4677521aa..0220654e0c7107aed90f932e32df86d6c03fea64 100644 (file)
@@ -13,7 +13,6 @@ def build_subcommands(subparsers) -> None:
     build_analyze_subcommand(subparsers)
     build_day_subcommand(subparsers)
     build_recipe_subcommand(subparsers)
-    build_biometric_subcommand(subparsers)
 
 
 ################################################################################
@@ -152,25 +151,3 @@ def build_recipe_subcommand(subparsers) -> None:
     recipe_delete_parser.set_defaults(func=parser_funcs.recipe_delete)
 
     recipe_parser.set_defaults(func=parser_funcs.recipes)
-
-
-def build_biometric_subcommand(subparsers) -> None:
-    """View biometrics, and view, add, edit, delete log entries"""
-    bio_parser = subparsers.add_parser("bio", help="view, add, remove biometric logs")
-    bio_subparsers = bio_parser.add_subparsers(title="biometric subcommands")
-
-    bio_log_parser = bio_subparsers.add_parser("log", help="manage biometric logs")
-    bio_log_subparsers = bio_log_parser.add_subparsers(
-        title="biometric log subcommands"
-    )
-    bio_log_parser.set_defaults(func=parser_funcs.bio_log)
-
-    bio_log_add_parser = bio_log_subparsers.add_parser(
-        "add", help="add a biometric log"
-    )
-    bio_log_add_parser.add_argument(
-        "biometric_val", help="id,value pairs, e.g. 22,59 23,110 24,65 ", nargs="+"
-    )
-    bio_log_add_parser.set_defaults(func=parser_funcs.bio_log_add)
-
-    bio_parser.set_defaults(func=parser_funcs.bio)
index d1a8605b0fd268d99992bb203d07c12e0d48c489..f64835f007d3873b3854d3a2340ad51fba539b17 100644 (file)
@@ -53,28 +53,6 @@ def day(args):
     return services.analyze.day_analyze(day_csv_paths, rda_csv_path=rda_csv_path)
 
 
-################################################################################
-# Biometrics
-################################################################################
-def bio():
-    """List biometrics"""
-    return services.biometrics.biometrics()
-
-
-def bio_log():
-    """List biometric logs"""
-    return services.biometrics.biometric_logs()
-
-
-def bio_log_add(args):
-    """Add a biometric log entry"""
-    bio_vals = {
-        int(x.split(",")[0]): float(x.split(",")[1]) for x in args.biometric_val
-    }
-
-    return services.biometrics.biometric_add(bio_vals)
-
-
 ################################################################################
 # Recipes
 ################################################################################
index a2455748d628963df01afeecd2b058b2cdd8344a..14a02e2ce2a26dc218a43b60d3151e4cf7e352a0 160000 (submodule)
@@ -1 +1 @@
-Subproject commit a2455748d628963df01afeecd2b058b2cdd8344a
+Subproject commit 14a02e2ce2a26dc218a43b60d3151e4cf7e352a0
index 2ee2d7078927ca3a7e38e5b0f3913fe8bec09f14..89919dccb7cf40a4fe275bc7065dbe3fc5996ebb 100644 (file)
@@ -58,36 +58,3 @@ def sql_recipe_add():
     query = """
 """
     return sql(query)
-
-
-################################################################################
-# Biometric functions
-################################################################################
-def sql_biometrics():
-    """Selects biometrics"""
-    query = "SELECT * FROM biometrics;"
-    return sql(query, headers=True)
-
-
-def sql_biometric_logs(profile_id):
-    """Selects biometric logs"""
-    query = "SELECT * FROM biometric_log WHERE profile_id=?"
-    return sql(query, values=(profile_id,), headers=True)
-
-
-def sql_biometric_add(bio_vals):
-    """Insert biometric log item"""
-    con = nt_sqlite_connect()
-    cur = con.cursor()
-
-    # TODO: finish up
-    query1 = "INSERT INTO biometric_log(profile_id, tags, notes) VALUES (?, ?, ?)"
-    sql(query1, (PROFILE_ID, "", ""))
-    log_id = cur.lastrowid
-    print(log_id)
-    query2 = "INSERT INTO bio_log_entry(log_id, biometric_id, value) VALUES (?, ?, ?)"
-    records = [
-        (log_id, biometric_id, value) for biometric_id, value in bio_vals.items()
-    ]
-    cur.executemany(query2, records)
-    return log_id
index e8898098b496272caf58abfe5c36e52794f6ed02..b57f0dbf9ded1c54c09fc5cebd26c18710bd8a19 100644 (file)
@@ -10,7 +10,7 @@ from ntclient import (
 from ntclient.ntsqlite.sql import build_ntsqlite
 from ntclient.persistence.sql.nt import nt_ver
 from ntclient.persistence.sql.usda import usda_init
-from ntclient.services import analyze, biometrics, recipe, usda
+from ntclient.services import analyze, recipe, usda
 from ntclient.utils.exceptions import SqlInvalidVersionError
 
 
diff --git a/ntclient/services/biometrics.py b/ntclient/services/biometrics.py
deleted file mode 100644 (file)
index 9ac8de1..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-"""Biometrics SQL functions"""
-from tabulate import tabulate
-
-from ntclient.persistence import PROFILE_ID
-from ntclient.persistence.sql.nt.funcs import (
-    sql_biometric_add,
-    sql_biometric_logs,
-    sql_biometrics,
-)
-
-
-def biometrics():
-    """Shows biometrics"""
-    headers, rows = sql_biometrics()
-    table = tabulate(rows, headers=headers, tablefmt="presto")
-    print(table)
-    return 0, rows
-
-
-def biometric_logs():
-    """Shows biometric logs"""
-    headers, rows = sql_biometric_logs(PROFILE_ID)
-
-    table = tabulate(rows, headers=headers, tablefmt="presto")
-    print(table)
-    return 0, rows
-
-
-def biometric_add(bio_vals):
-    """Add a biometric type"""
-    print()
-    # print("New biometric log: " + name + "\n")
-
-    bio_names = {x[0]: x for x in sql_biometrics()[1]}
-
-    results = []
-    for biometric_id, value in bio_vals.items():
-        bio = bio_names[biometric_id]
-        results.append(
-            {"id": biometric_id, "name": bio[1], "value": value, "unit": bio[2]}
-        )
-
-    table = tabulate(results, headers="keys", tablefmt="presto")
-    print(table)
-
-    # TODO: print current profile and date?
-
-    confirm = input("\nConfirm add biometric? [Y/n] ")
-
-    if confirm.lower() == "y":
-        sql_biometric_add(bio_vals)
-        print("not implemented ;]")
-    return 1, False
index 1d314cffae6450cf9554a23398349b3bbd2b832e..7790bcaabb6af00f4e2cfc9225076ad198ac5cd9 100644 (file)
@@ -71,9 +71,7 @@ def test_200_nt_sql_funcs():
     version = nt_ver()
     assert version == __db_target_nt__
 
-    headers, rows = nt_funcs.sql_biometrics()
-    assert headers == ["id", "name", "unit", "created"]
-    assert len(rows) == 29
+    # TODO: add more tests, it used to poll biometrics
 
 
 def test_300_argparser_debug_no_paging():
@@ -190,19 +188,21 @@ def test_500_main_module():
 
 def test_600_sql_integrity_error__service_wip():
     """Provokes IntegrityError in nt.sqlite3"""
-    from ntclient.services import biometrics  # pylint: disable=import-outside-toplevel
-
-    args = arg_parser.parse_args(args=["-d", "bio", "log", "add", "12,12"])
-    biometrics.input = (
-        lambda x: "y"
-    )  # mocks input, could also pass `-y` flag or set yes=True
-
-    with pytest.raises(sqlite3.IntegrityError) as integrity_error:
-        args.func(args)
-    assert (
-        integrity_error.value.args[0]
-        == "NOT NULL constraint failed: biometric_log.profile_id"
-    )
+
+    # TODO: replace with non-biometric test
+    # from ntclient.services import biometrics  # pylint: disable=import-outside-toplevel
+    #
+    # args = arg_parser.parse_args(args=["-d", "bio", "log", "add", "12,12"])
+    # biometrics.input = (
+    #     lambda x: "y"
+    # )  # mocks input, could also pass `-y` flag or set yes=True
+    #
+    # with pytest.raises(sqlite3.IntegrityError) as integrity_error:
+    #     args.func(args)
+    # assert (
+    #     integrity_error.value.args[0]
+    #     == "NOT NULL constraint failed: biometric_log.profile_id"
+    # )
 
 
 def test_700_build_ntsqlite_succeeds():