-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseed.py
More file actions
150 lines (129 loc) · 5.25 KB
/
Copy pathseed.py
File metadata and controls
150 lines (129 loc) · 5.25 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
from datetime import date, datetime, timedelta
from app import app
from models import db, User, UserProfile, WorkoutEntry, MealEntry
def seed():
with app.app_context():
print("Dropping and creating tables...")
db.drop_all()
db.create_all()
# ---------- USERS ----------
user1 = User(
email="test@staybalanced.com",
password_hash="test123", # TODO: hash later
name="Test User",
created_at=datetime.now(),
)
user2 = User(
email="demo@staybalanced.com",
password_hash="demo123", # TODO: hash later
name="Demo User",
created_at=datetime.now(),
)
db.session.add_all([user1, user2])
db.session.commit()
print(f"Created users: {user1.id} (test), {user2.id} (demo)")
# ---------- PROFILES (SURVEY DATA + GOALS) ----------
profile1 = UserProfile(
user_id=user1.id,
fitness_goal="Build Muscle",
activity_level="Active",
diet_type="No Restrictions",
allergies="None",
workout_days="Mon,Wed,Fri",
notifications_enabled=True,
target_weight_kg=80,
current_weight_kg=78,
height_cm=178,
daily_calorie_goal=2600,
daily_protein_goal_g=150,
daily_carb_goal_g=260,
daily_fat_goal_g=70,
)
profile2 = UserProfile(
user_id=user2.id,
fitness_goal="Lose Weight",
activity_level="Lightly Active",
diet_type="No Restrictions",
allergies="Peanuts",
workout_days="Tue,Thu,Sat",
notifications_enabled=False,
target_weight_kg=65,
current_weight_kg=72,
height_cm=165,
daily_calorie_goal=1900,
daily_protein_goal_g=110,
daily_carb_goal_g=180,
daily_fat_goal_g=60,
)
db.session.add_all([profile1, profile2])
db.session.commit()
# ---------- WORKOUTS & MEALS FOR LAST 5 DAYS ----------
today = date.today()
# Helper to add workout
def add_workout(user, day_offset, name, muscle_group,
sets, reps, minutes, intensity, status="completed"):
d = today - timedelta(days=day_offset)
w = WorkoutEntry(
user_id=user.id,
date=d,
workout_name=name,
muscle_group=muscle_group,
sets=sets,
reps=reps,
duration_minutes=minutes,
intensity=intensity,
status=status,
)
db.session.add(w)
# Helper to add meal
def add_meal(user, day_offset, meal_type, name,
calories, protein, carbs, fats):
d = today - timedelta(days=day_offset)
m = MealEntry(
user_id=user.id,
date=d,
meal_type=meal_type,
meal_name=name,
calories=calories,
protein_g=protein,
carbs_g=carbs,
fats_g=fats,
)
db.session.add(m)
# ---------- USER 1: Test User ----------
# Workouts over last 5 days
add_workout(user1, 0, "Upper Body Day", "Chest", 4, 10, 45, "Medium")
add_workout(user1, 1, "Leg Day", "Legs", 5, 8, 50, "High")
add_workout(user1, 3, "Cardio Session", "Full Body", 0, 0, 30, "Low", status="completed")
# Meals over last 5 days
# Today
add_meal(user1, 0, "Breakfast", "Oatmeal & Berries", 400, 15, 60, 8)
add_meal(user1, 0, "Lunch", "Chicken & Rice", 650, 45, 70, 15)
add_meal(user1, 0, "Dinner", "Salmon & Veggies", 700, 40, 40, 30)
add_meal(user1, 0, "Snack", "Greek Yogurt", 200, 18, 15, 4)
# Yesterday
add_meal(user1, 1, "Breakfast", "Eggs & Toast", 450, 25, 35, 18)
add_meal(user1, 1, "Lunch", "Turkey Sandwich", 550, 30, 55, 12)
add_meal(user1, 1, "Dinner", "Pasta & Meatballs", 800, 35, 90, 22)
# 3 days ago (lighter day)
add_meal(user1, 3, "Lunch", "Chicken Salad", 450, 35, 25, 14)
add_meal(user1, 3, "Dinner", "Stir Fry Veggies & Tofu", 600, 28, 65, 18)
# ---------- USER 2: Demo User ----------
# Workouts
add_workout(user2, 0, "Light Cardio", "Full Body", 0, 0, 25, "Low")
add_workout(user2, 2, "Beginner Full-Body", "Full Body", 3, 12, 35, "Medium")
# Meals
add_meal(user2, 0, "Breakfast", "Smoothie Bowl", 350, 20, 50, 8)
add_meal(user2, 0, "Lunch", "Grilled Chicken Wrap", 550, 35, 50, 16)
add_meal(user2, 0, "Dinner", "Veggie Soup & Bread", 500, 18, 60, 10)
add_meal(user2, 2, "Lunch", "Quinoa Salad", 480, 20, 55, 14)
add_meal(user2, 2, "Dinner", "Baked Fish & Rice", 650, 40, 55, 18)
# Commit all workouts/meals
db.session.commit()
# Debug summary
meal_count = MealEntry.query.count()
workout_count = WorkoutEntry.query.count()
user_count = User.query.count()
print(f"Seeding complete. Users: {user_count}, Meals: {meal_count}, Workouts: {workout_count}")
if __name__ == "__main__":
seed()