Spaces:
Sleeping
Sleeping
Download app/models/progress.py from baljot07/studiq-backend: direct link, hf CLI and curl.
- Browser
- Download file 1.49 kB
-
https://huggingface.co/spaces/baljot07/studiq-backend/resolve/main/app/models/progress.py
- Command line
-
hf download hf://spaces/baljot07/studiq-backend/app/models/progress.py
-
curl -L -o progress.py https://huggingface.co/spaces/baljot07/studiq-backend/resolve/main/app/models/progress.py
1.49 kB
| """UserProgress model — tracks per-topic study progress for each student.""" | |
| import uuid | |
| from datetime import datetime | |
| from typing import Optional | |
| from sqlalchemy import ForeignKey, Index, Integer, String, UniqueConstraint | |
| from sqlalchemy.orm import Mapped, mapped_column | |
| from sqlalchemy.sql import func | |
| from app.models.base import Base | |
| class UserProgress(Base): | |
| """Tracks a student's progress on individual syllabus topics.""" | |
| __tablename__ = "user_progress" | |
| __table_args__ = ( | |
| UniqueConstraint("user_id", "topic_id", name="uq_user_topic"), | |
| Index("ix_user_progress_user_subject", "user_id", "subject_code"), | |
| ) | |
| id: Mapped[uuid.UUID] = mapped_column( | |
| primary_key=True, default=uuid.uuid4 | |
| ) | |
| user_id: Mapped[uuid.UUID] = mapped_column( | |
| ForeignKey("users.id", ondelete="CASCADE"), | |
| nullable=False, | |
| index=True, | |
| ) | |
| topic_id: Mapped[str] = mapped_column(String(255), nullable=False) | |
| subject_code: Mapped[Optional[str]] = mapped_column( | |
| String(255), nullable=True | |
| ) | |
| status: Mapped[str] = mapped_column( | |
| String(20), default="not_started" | |
| ) # not_started / in_progress / completed | |
| strength_score: Mapped[int] = mapped_column(Integer, default=0) | |
| time_spent_minutes: Mapped[int] = mapped_column(Integer, default=0) | |
| last_studied_at: Mapped[Optional[datetime]] = mapped_column(nullable=True) | |
| created_at: Mapped[datetime] = mapped_column(server_default=func.now()) | |