Add boto3 dependency and update exercise/machine assets
- Added boto3 as a dependency in pyproject.toml and uv.lock. - Introduced multiple new exercise images in various formats (jpg, webp, avif, png). - Added new machine images to enhance the workout assets library.
This commit is contained in:
@@ -48,6 +48,49 @@ class Equipment(Base, TimestampMixin):
|
||||
workout_items: Mapped[list[WorkoutItem]] = relationship(back_populates="equipment")
|
||||
|
||||
|
||||
class ActivitySource(Base, TimestampMixin):
|
||||
__tablename__ = "logic_activity_sources"
|
||||
__table_args__ = (
|
||||
CheckConstraint("kind IN ('exercise', 'machine')", name="ck_activity_source_kind"),
|
||||
CheckConstraint(
|
||||
"category IN ('chest', 'back', 'legs', 'shoulders', 'biceps', 'triceps', "
|
||||
"'core', 'cardio', 'full_body', 'other')",
|
||||
name="ck_activity_source_category",
|
||||
),
|
||||
CheckConstraint(
|
||||
"equipment IN ('barbell', 'dumbbell', 'machine', 'cable', 'bodyweight', "
|
||||
"'kettlebell', 'cardio_machine', 'other')",
|
||||
name="ck_activity_source_equipment",
|
||||
),
|
||||
CheckConstraint(
|
||||
"measurement_type IN ('weight_reps', 'reps_only', 'duration', "
|
||||
"'distance_duration', 'duration_calories')",
|
||||
name="ck_activity_source_measurement_type",
|
||||
),
|
||||
CheckConstraint(
|
||||
"difficulty IN ('beginner', 'intermediate', 'advanced')",
|
||||
name="ck_activity_source_difficulty",
|
||||
),
|
||||
)
|
||||
|
||||
id: Mapped[uuid.UUID] = uuid_pk()
|
||||
owner_user_id: Mapped[uuid.UUID | None] = mapped_column(UUID(as_uuid=True), index=True)
|
||||
slug: Mapped[str] = mapped_column(String(180), unique=True, index=True)
|
||||
kind: Mapped[str] = mapped_column(String(20), index=True)
|
||||
title: Mapped[str] = mapped_column(String(160), index=True)
|
||||
description: Mapped[str | None] = mapped_column(Text)
|
||||
category: Mapped[str] = mapped_column(String(32), index=True)
|
||||
equipment: Mapped[str] = mapped_column(String(32), index=True)
|
||||
measurement_type: Mapped[str] = mapped_column(String(32))
|
||||
difficulty: Mapped[str] = mapped_column(String(20), default="intermediate")
|
||||
image_s3_url: Mapped[str | None] = mapped_column(Text)
|
||||
image_s3_key: Mapped[str | None] = mapped_column(Text)
|
||||
is_builtin: Mapped[bool] = mapped_column(Boolean, default=False, index=True)
|
||||
default_calories_per_minute: Mapped[float | None] = mapped_column(Numeric(8, 2))
|
||||
|
||||
workout_items: Mapped[list[WorkoutItem]] = relationship(back_populates="activity_source")
|
||||
|
||||
|
||||
class Exercise(Base, TimestampMixin):
|
||||
__tablename__ = "logic_exercises"
|
||||
|
||||
@@ -93,12 +136,13 @@ class WorkoutItem(Base):
|
||||
__tablename__ = "logic_workout_items"
|
||||
__table_args__ = (
|
||||
CheckConstraint(
|
||||
"(exercise_id IS NOT NULL AND equipment_id IS NULL) OR "
|
||||
"(exercise_id IS NULL AND equipment_id IS NOT NULL)",
|
||||
"(CASE WHEN activity_source_id IS NOT NULL THEN 1 ELSE 0 END + "
|
||||
"CASE WHEN exercise_id IS NOT NULL THEN 1 ELSE 0 END + "
|
||||
"CASE WHEN equipment_id IS NOT NULL THEN 1 ELSE 0 END) = 1",
|
||||
name="ck_workout_item_exactly_one_entity",
|
||||
),
|
||||
CheckConstraint(
|
||||
"source_kind IN ('exercise', 'equipment')",
|
||||
"source_kind IN ('exercise', 'machine', 'equipment')",
|
||||
name="ck_workout_item_source_kind",
|
||||
),
|
||||
)
|
||||
@@ -110,6 +154,12 @@ class WorkoutItem(Base):
|
||||
source_kind: Mapped[str] = mapped_column(String(20))
|
||||
title_snapshot: Mapped[str] = mapped_column(String(160))
|
||||
image_s3_url_snapshot: Mapped[str | None] = mapped_column(Text)
|
||||
measurement_type_snapshot: Mapped[str] = mapped_column(String(32), default="weight_reps")
|
||||
category_snapshot: Mapped[str] = mapped_column(String(32), default="other")
|
||||
equipment_snapshot: Mapped[str] = mapped_column(String(32), default="other")
|
||||
activity_source_id: Mapped[uuid.UUID | None] = mapped_column(
|
||||
ForeignKey("logic_activity_sources.id")
|
||||
)
|
||||
exercise_id: Mapped[uuid.UUID | None] = mapped_column(ForeignKey("logic_exercises.id"))
|
||||
equipment_id: Mapped[uuid.UUID | None] = mapped_column(ForeignKey("logic_equipment.id"))
|
||||
order_index: Mapped[int] = mapped_column(Integer, default=0)
|
||||
@@ -117,6 +167,7 @@ class WorkoutItem(Base):
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=now)
|
||||
|
||||
workout: Mapped[Workout] = relationship(back_populates="items")
|
||||
activity_source: Mapped[ActivitySource | None] = relationship(back_populates="workout_items")
|
||||
exercise: Mapped[Exercise | None] = relationship(back_populates="workout_items")
|
||||
equipment: Mapped[Equipment | None] = relationship(back_populates="workout_items")
|
||||
sets: Mapped[list[WorkoutSet]] = relationship(
|
||||
@@ -135,6 +186,7 @@ class WorkoutSet(Base):
|
||||
weight: Mapped[float] = mapped_column(Numeric(8, 2), default=0)
|
||||
reps: Mapped[int] = mapped_column(Integer, default=0)
|
||||
duration_seconds: Mapped[int | None] = mapped_column(Integer)
|
||||
distance_km: Mapped[float | None] = mapped_column(Numeric(8, 3))
|
||||
calories: Mapped[float | None] = mapped_column(Numeric(8, 2))
|
||||
completed_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=now)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user