| 35 | |
| 36 | |
| 37 | class PracticeSession(SQLModel, table=True): |
| 38 | id: uuid.UUID | None = Field(default_factory=uuid.uuid4, primary_key=True) |
| 39 | collection_id: uuid.UUID = Field(foreign_key="collection.id", index=True) |
| 40 | user_id: uuid.UUID = Field(foreign_key="user.id", index=True, ondelete="CASCADE") |
| 41 | user: "User" = Relationship(back_populates="practice_sessions") |
| 42 | is_completed: bool = Field(default=False) |
| 43 | total_cards: int = Field(default=0) |
| 44 | cards_practiced: int = Field(default=0) |
| 45 | correct_answers: int = Field(default=0) |
| 46 | created_at: datetime = Field( |
| 47 | default_factory=lambda: datetime.now(timezone.utc), index=True |
| 48 | ) |
| 49 | updated_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc)) |
| 50 | collection: Collection = Relationship(back_populates="practice_sessions") |
| 51 | practice_cards: list["PracticeCard"] = Relationship( |
| 52 | back_populates="session", cascade_delete=True |
| 53 | ) |
| 54 | |
| 55 | |
| 56 | class PracticeCard(SQLModel, table=True): |
no outgoing calls