All tweaks added
This commit is contained in:
@@ -22,9 +22,39 @@ class User(Base):
|
||||
pocketid_sub = Column(String(256), unique=True, nullable=True)
|
||||
created_at = Column(DateTime(timezone=True), default=now_utc)
|
||||
|
||||
# Health profile
|
||||
max_heart_rate = Column(Integer, nullable=True)
|
||||
resting_heart_rate = Column(Integer, nullable=True)
|
||||
birth_year = Column(Integer, nullable=True)
|
||||
height_cm = Column(Float, nullable=True)
|
||||
|
||||
# PocketID config (stored per-user so admin can set via UI)
|
||||
pocketid_issuer = Column(String(512), nullable=True)
|
||||
pocketid_client_id = Column(String(256), nullable=True)
|
||||
pocketid_client_secret = Column(String(256), nullable=True)
|
||||
|
||||
activities = relationship("Activity", back_populates="user", cascade="all, delete-orphan")
|
||||
health_metrics = relationship("HealthMetric", back_populates="user", cascade="all, delete-orphan")
|
||||
named_routes = relationship("NamedRoute", back_populates="user", cascade="all, delete-orphan")
|
||||
weight_logs = relationship("WeightLog", back_populates="user", cascade="all, delete-orphan")
|
||||
|
||||
|
||||
class WeightLog(Base):
|
||||
"""Manual weight entries separate from health_metrics for easy tracking."""
|
||||
__tablename__ = "weight_logs"
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
user_id = Column(Integer, ForeignKey("users.id"), nullable=False, index=True)
|
||||
date = Column(DateTime(timezone=True), nullable=False)
|
||||
weight_kg = Column(Float, nullable=False)
|
||||
body_fat_pct = Column(Float, nullable=True)
|
||||
note = Column(String(256), nullable=True)
|
||||
|
||||
__table_args__ = (
|
||||
Index("ix_weight_user_date", "user_id", "date"),
|
||||
)
|
||||
|
||||
user = relationship("User", back_populates="weight_logs")
|
||||
|
||||
|
||||
class Activity(Base):
|
||||
@@ -68,11 +98,6 @@ class Activity(Base):
|
||||
|
||||
|
||||
class ActivityDataPoint(Base):
|
||||
"""
|
||||
TimescaleDB hypertable - one row per second of activity data.
|
||||
Composite primary key (activity_id, timestamp) satisfies TimescaleDB's
|
||||
requirement that the partition column be part of the primary key.
|
||||
"""
|
||||
__tablename__ = "activity_data_points"
|
||||
|
||||
activity_id = Column(Integer, ForeignKey("activities.id"), nullable=False, primary_key=True)
|
||||
@@ -118,6 +143,7 @@ class NamedRoute(Base):
|
||||
reference_polyline = Column(Text, nullable=True)
|
||||
bounding_box = Column(JSON, nullable=True)
|
||||
distance_m = Column(Float, nullable=True)
|
||||
auto_detected = Column(Boolean, default=False)
|
||||
created_at = Column(DateTime(timezone=True), default=now_utc)
|
||||
|
||||
user = relationship("User", back_populates="named_routes")
|
||||
@@ -198,4 +224,4 @@ class HealthMetric(Base):
|
||||
Index("ix_health_user_date", "user_id", "date"),
|
||||
)
|
||||
|
||||
user = relationship("User", back_populates="health_metrics")
|
||||
user = relationship("User", back_populates="health_metrics")
|
||||
|
||||
Reference in New Issue
Block a user