forked from abhimana2003/BigDataNutritionAgent
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
71 lines (59 loc) · 2.73 KB
/
Copy pathmodels.py
File metadata and controls
71 lines (59 loc) · 2.73 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
from sqlalchemy import Column, Integer, String, Float, ARRAY, JSON, ForeignKey, Date, DateTime
from database import Base
from sqlalchemy.orm import relationship
from datetime import datetime
class UserProfile(Base):
__tablename__ = "user_profiles"
id = Column(Integer, primary_key=True, index=True)
username = Column(String, unique=True, index=True, nullable=False)
email = Column(String, unique=True, index=True, nullable=True)
full_name = Column(String, nullable=True)
password_hash = Column(String, nullable=True)
password_salt = Column(String, nullable=True)
age = Column(Integer, nullable=False)
height_feet = Column(Integer, nullable=False)
height_inches = Column(Integer, nullable=False)
weight = Column(Float, nullable=False)
gender = Column(String, nullable=False)
goal = Column(String, nullable=False)
dietary_preferences = Column(ARRAY(String), default=[])
allergies = Column(ARRAY(String), default=[])
medical_conditions = Column(ARRAY(String), default=[])
budget_level = Column(String)
cooking_time = Column(String)
recipes = relationship("Recipe", back_populates="user")
class Recipe(Base):
__tablename__ = "recipes"
id = Column(Integer, primary_key=True, index=True)
recipe_name = Column(String, nullable=False)
prep_time = Column(Integer)
cook_time = Column(Integer)
total_time = Column(Integer)
servings = Column(Integer)
ingredients = Column(JSON)
directions = Column(JSON)
rating = Column(Float)
url = Column(String)
cuisine_path = Column(String)
nutrition = Column(JSON)
timing = Column(JSON)
dietary_tags = Column(JSON)
estimated_cost = Column(Float)
username = Column(String, ForeignKey("user_profiles.username"))
user = relationship("UserProfile", back_populates="recipes")
category = Column(String, nullable=True, index=True)
class MealPlanHistory(Base):
__tablename__ = "meal_plan_history"
id = Column(Integer, primary_key=True, index=True)
username = Column(String, ForeignKey("user_profiles.username"), index=True, nullable=False)
week_start = Column(Date, nullable=False, index=True)
recipe_ids = Column(JSON, nullable=False, default=list)
meal_plan = Column(JSON, nullable=True)
created_at = Column(DateTime, nullable=False, default=datetime.utcnow)
class UserFeedback(Base):
__tablename__ = "user_feedback"
id = Column(Integer, primary_key=True, index=True)
user_id = Column(Integer, ForeignKey("user_profiles.id"), index=True, nullable=False)
recipe_id = Column(Integer, ForeignKey("recipes.id"), index=True, nullable=False)
action = Column(String, nullable=False)
created_at = Column(DateTime, nullable=False, default=datetime.utcnow, index=True)