DocDoeAI / app /models /phase3_activity.py
asnannp's picture
Deploy backend cd4237ff: support routes + rate limit + exam_date nullable + upload 413 fix
7c6ffa6
Raw
History Blame Contribute Delete
1.32 kB
from __future__ import annotations
from datetime import datetime
from typing import Any
from sqlalchemy import DateTime, ForeignKey, JSON, String, func
from sqlalchemy.orm import Mapped, mapped_column
from app.core.database import Base
from app.utils.ids import prefixed_id
class Phase3Activity(Base):
"""Per-user learning-support activity aggregate.
Backs the localStorage Phase3Activity blob that drives the PYQ result,
revision queue, weak areas, and progress pages. One row per user, stored as
a JSON blob so the shape can evolve freely.
"""
__tablename__ = "phase3_activity"
id: Mapped[str] = mapped_column(
String(40),
primary_key=True,
default=lambda: prefixed_id("p3act"),
)
user_id: Mapped[str] = mapped_column(
String(40),
ForeignKey("users.id"),
index=True,
unique=True,
nullable=False,
)
data: Mapped[dict[str, Any]] = mapped_column(JSON, default=dict, nullable=False)
created_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True),
server_default=func.now(),
nullable=False,
)
updated_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True),
server_default=func.now(),
onupdate=func.now(),
nullable=False,
)