Register adaptive medication API routes
This commit is contained in:
22
api/main.py
22
api/main.py
@@ -21,6 +21,7 @@ import api.routes.notifications as notifications_routes
|
|||||||
import api.routes.preferences as preferences_routes
|
import api.routes.preferences as preferences_routes
|
||||||
import api.routes.rewards as rewards_routes
|
import api.routes.rewards as rewards_routes
|
||||||
import api.routes.victories as victories_routes
|
import api.routes.victories as victories_routes
|
||||||
|
import api.routes.adaptive_meds as adaptive_meds_routes
|
||||||
|
|
||||||
app = flask.Flask(__name__)
|
app = flask.Flask(__name__)
|
||||||
CORS(app)
|
CORS(app)
|
||||||
@@ -37,6 +38,7 @@ ROUTE_MODULES = [
|
|||||||
preferences_routes,
|
preferences_routes,
|
||||||
rewards_routes,
|
rewards_routes,
|
||||||
victories_routes,
|
victories_routes,
|
||||||
|
adaptive_meds_routes,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@@ -161,8 +163,13 @@ def _seed_templates_if_empty():
|
|||||||
count = postgres.count("routine_templates")
|
count = postgres.count("routine_templates")
|
||||||
if count == 0:
|
if count == 0:
|
||||||
import logging
|
import logging
|
||||||
logging.getLogger(__name__).info("No templates found, seeding from seed_templates.sql...")
|
|
||||||
seed_path = os.path.join(os.path.dirname(__file__), "..", "config", "seed_templates.sql")
|
logging.getLogger(__name__).info(
|
||||||
|
"No templates found, seeding from seed_templates.sql..."
|
||||||
|
)
|
||||||
|
seed_path = os.path.join(
|
||||||
|
os.path.dirname(__file__), "..", "config", "seed_templates.sql"
|
||||||
|
)
|
||||||
if os.path.exists(seed_path):
|
if os.path.exists(seed_path):
|
||||||
with open(seed_path, "r") as f:
|
with open(seed_path, "r") as f:
|
||||||
sql = f.read()
|
sql = f.read()
|
||||||
@@ -171,6 +178,7 @@ def _seed_templates_if_empty():
|
|||||||
logging.getLogger(__name__).info("Templates seeded successfully.")
|
logging.getLogger(__name__).info("Templates seeded successfully.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
logging.getLogger(__name__).warning(f"Failed to seed templates: {e}")
|
logging.getLogger(__name__).warning(f"Failed to seed templates: {e}")
|
||||||
|
|
||||||
|
|
||||||
@@ -180,8 +188,13 @@ def _seed_rewards_if_empty():
|
|||||||
count = postgres.count("reward_pool")
|
count = postgres.count("reward_pool")
|
||||||
if count == 0:
|
if count == 0:
|
||||||
import logging
|
import logging
|
||||||
logging.getLogger(__name__).info("No rewards found, seeding from seed_rewards.sql...")
|
|
||||||
seed_path = os.path.join(os.path.dirname(__file__), "..", "config", "seed_rewards.sql")
|
logging.getLogger(__name__).info(
|
||||||
|
"No rewards found, seeding from seed_rewards.sql..."
|
||||||
|
)
|
||||||
|
seed_path = os.path.join(
|
||||||
|
os.path.dirname(__file__), "..", "config", "seed_rewards.sql"
|
||||||
|
)
|
||||||
if os.path.exists(seed_path):
|
if os.path.exists(seed_path):
|
||||||
with open(seed_path, "r") as f:
|
with open(seed_path, "r") as f:
|
||||||
sql = f.read()
|
sql = f.read()
|
||||||
@@ -190,6 +203,7 @@ def _seed_rewards_if_empty():
|
|||||||
logging.getLogger(__name__).info("Rewards seeded successfully.")
|
logging.getLogger(__name__).info("Rewards seeded successfully.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
logging.getLogger(__name__).warning(f"Failed to seed rewards: {e}")
|
logging.getLogger(__name__).warning(f"Failed to seed rewards: {e}")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user