hale-api / debug_hale_db.py
Raunak211006's picture
Deploy v3.2 to Hugging Face (excluding binaries)
c50a873
Raw
History Blame Contribute Delete
1.62 kB
import os
import sys
import json
from datetime import date
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
# Add app to path
sys.path.insert(0, os.path.abspath('.'))
from app.core.config import settings
from app.models.user import User
from app.models.goal import Goal
from app.models.progress import Progress
def debug_db():
engine = create_engine(settings.DATABASE_URL)
SessionLocal = sessionmaker(bind=engine)
db = SessionLocal()
try:
user_id = "testuser"
user = db.query(User).filter(User.user_id == user_id).first()
if not user:
print(f"User {user_id} not found")
return
print(f"--- User: {user.user_id} ---")
print(f"XP: {user.xp}, Level: {user.level}, Streak: {user.current_streak}")
goals = db.query(Goal).filter(Goal.user_id == user_id).all()
print(f"\n--- Goals ({len(goals)}) ---")
for g in goals:
print(f"ID: {g.id}, Text: {g.goal_text}, Active: {g.is_active}, Completed: {g.is_completed}")
# print(f"Plan JSON: {g.plan_json[:100]}...")
today = date.today().isoformat()
print(f"\n--- Progress for Today ({today}) ---")
progress_today = db.query(Progress).filter(Progress.user_id == user_id, Progress.date == today).all()
for p in progress_today:
print(f"ID: {p.id}, GoalID: {p.goal_id}, Topic: {p.topic}, Completed: {p.completed}")
print(f"Tasks: {p.tasks}")
finally:
db.close()
if __name__ == "__main__":
debug_db()