This is the initial push of the outline of the life dashboard
This commit is contained in:
12
backend/app/models/__init__.py
Normal file
12
backend/app/models/__init__.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from app.models.weight import WeightEntry
|
||||
from app.models.workout import Exercise, Workout, WorkoutSet
|
||||
from app.models.finance import FinanceTransaction, FinanceSnapshot
|
||||
|
||||
__all__ = [
|
||||
"WeightEntry",
|
||||
"Exercise",
|
||||
"Workout",
|
||||
"WorkoutSet",
|
||||
"FinanceTransaction",
|
||||
"FinanceSnapshot",
|
||||
]
|
||||
26
backend/app/models/finance.py
Normal file
26
backend/app/models/finance.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from datetime import date, datetime
|
||||
|
||||
from sqlalchemy import Date, Numeric, Text, func
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from app.database import Base
|
||||
|
||||
|
||||
class FinanceTransaction(Base):
|
||||
__tablename__ = "finance_transactions"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
date: Mapped[date] = mapped_column(Date)
|
||||
amount: Mapped[float] = mapped_column(Numeric(12, 2))
|
||||
category: Mapped[str] = mapped_column(Text)
|
||||
description: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
created_at: Mapped[datetime] = mapped_column(server_default=func.now())
|
||||
|
||||
|
||||
class FinanceSnapshot(Base):
|
||||
__tablename__ = "finance_snapshots"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
date: Mapped[date] = mapped_column(Date, unique=True)
|
||||
net_worth: Mapped[float] = mapped_column(Numeric(14, 2))
|
||||
notes: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
17
backend/app/models/weight.py
Normal file
17
backend/app/models/weight.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from datetime import date, datetime
|
||||
|
||||
from sqlalchemy import Date, Numeric, Text, func
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from app.database import Base
|
||||
|
||||
|
||||
class WeightEntry(Base):
|
||||
__tablename__ = "weight_entries"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
date: Mapped[date] = mapped_column(Date, unique=True)
|
||||
weight_lbs: Mapped[float] = mapped_column(Numeric(5, 1))
|
||||
body_fat_pct: Mapped[float | None] = mapped_column(Numeric(4, 1), nullable=True)
|
||||
notes: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
created_at: Mapped[datetime] = mapped_column(server_default=func.now())
|
||||
43
backend/app/models/workout.py
Normal file
43
backend/app/models/workout.py
Normal file
@@ -0,0 +1,43 @@
|
||||
from datetime import date, datetime
|
||||
|
||||
from sqlalchemy import Date, ForeignKey, Integer, Numeric, Text, func
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from app.database import Base
|
||||
|
||||
|
||||
class Exercise(Base):
|
||||
__tablename__ = "exercises"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
name: Mapped[str] = mapped_column(Text, unique=True)
|
||||
category: Mapped[str] = mapped_column(Text)
|
||||
|
||||
|
||||
class Workout(Base):
|
||||
__tablename__ = "workouts"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
date: Mapped[date] = mapped_column(Date)
|
||||
name: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
notes: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
created_at: Mapped[datetime] = mapped_column(server_default=func.now())
|
||||
|
||||
sets: Mapped[list["WorkoutSet"]] = relationship(
|
||||
back_populates="workout", cascade="all, delete-orphan"
|
||||
)
|
||||
|
||||
|
||||
class WorkoutSet(Base):
|
||||
__tablename__ = "workout_sets"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
workout_id: Mapped[int] = mapped_column(ForeignKey("workouts.id", ondelete="CASCADE"))
|
||||
exercise_id: Mapped[int] = mapped_column(ForeignKey("exercises.id"))
|
||||
set_number: Mapped[int] = mapped_column(Integer)
|
||||
reps: Mapped[int | None] = mapped_column(Integer, nullable=True)
|
||||
weight_lbs: Mapped[float | None] = mapped_column(Numeric(6, 1), nullable=True)
|
||||
duration_min: Mapped[float | None] = mapped_column(Numeric(5, 1), nullable=True)
|
||||
|
||||
workout: Mapped["Workout"] = relationship(back_populates="sets")
|
||||
exercise: Mapped["Exercise"] = relationship()
|
||||
Reference in New Issue
Block a user