31 lines
929 B
Python
31 lines
929 B
Python
"""Модели БД."""
|
|
import uuid
|
|
from datetime import datetime, timezone
|
|
|
|
from sqlalchemy import Column, String, Integer, Boolean, DateTime, Numeric
|
|
|
|
from app.database import Base
|
|
|
|
|
|
def gen_uuid():
|
|
return str(uuid.uuid4())
|
|
|
|
|
|
def utc_now():
|
|
return datetime.now(timezone.utc)
|
|
|
|
|
|
class Participant(Base):
|
|
"""Участник обучения: ФИО, старт, завершение теста, результат."""
|
|
|
|
__tablename__ = "participants"
|
|
|
|
id = Column(String(36), primary_key=True, default=gen_uuid)
|
|
fio = Column(String(500), nullable=False, index=True)
|
|
started_at = Column(DateTime(timezone=True), nullable=False, default=utc_now)
|
|
completed_at = Column(DateTime(timezone=True), nullable=True)
|
|
score = Column(Integer, nullable=True)
|
|
total_questions = Column(Integer, nullable=True)
|
|
percent = Column(Numeric(5, 2), nullable=True)
|
|
passed = Column(Boolean, nullable=True)
|