File size: 2,608 Bytes
c50a873
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import os
import sys
from datetime import datetime

# Add app to path
sys.path.insert(0, os.path.abspath('.'))

from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from app.core.database import Base, get_db, SessionLocal
from app.models.user import User
from app.models.goal import Goal
from app.core.security import hash_password
from app.core.config import settings


def seed():
    db = SessionLocal()
    try:
        # 1. Create User
        username = "testuser"
        existing = db.query(User).filter(User.user_id == username).first()
        if existing:
            print(f"User {username} already exists. Cleaning up old data...")
            db.delete(existing)
            db.commit()

        user = User(
            user_id=username,
            name="Test Explorer",
            email="test@example.com",
            hashed_password=hash_password("Password123"),
            coach_personality="supportive"
        )
        db.add(user)
        db.commit()
        db.refresh(user)
        print(f"Created user: {username}")

        # 2. Create Goal
        # Note: We bypass LLM generation for speed by providing a mock plan_json
        mock_plan = {
            "goal": "Master Next.js & FastAPI",
            "duration_days": 30,
            "modules": [
                {
                    "title": "Module 1: Foundations",
                    "duration_days": 7,
                    "outcomes": ["Understand core concepts"],
                    "tasks": [
                        {"title": "Setup development environment", "duration_min": 30, "deliverable": "Working dev server"},
                        {"title": "Learn FastAPI routing", "duration_min": 45, "deliverable": "Simple API"},
                        {"title": "Build Next.js components", "duration_min": 60, "deliverable": "UI Page"}
                    ]
                }
            ],
            "meta": {"llm_used": False, "confidence": 1.0}
        }
        
        import json
        goal = Goal(
            user_id=user.user_id,
            goal_text="Master Next.js & FastAPI",
            category="coding",
            duration_days=30,
            plan_json=json.dumps(mock_plan),
            is_active=True
        )
        db.add(goal)
        db.commit()
        print(f"Created goal: {goal.goal_text}")

        print("\n--- Seeding Complete! ---")
        print(f"Username: {username}")
        print(f"Password: Password123")

    except Exception as e:
        print(f"Error seeding data: {e}")
    finally:
        db.close()

if __name__ == "__main__":
    seed()