Files
vidconf/backend/models/phrase.py

37 lines
1.6 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Модель Phrase — фраза транскрибации, атрибутированная к участнику сеанса (ADR-002)."""
import uuid
from datetime import datetime
from sqlalchemy import BigInteger, DateTime, ForeignKey, Identity, Index, Text
from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.orm import Mapped, mapped_column
from models.base import Base
class Phrase(Base):
"""Одна восстановленная фраза, относящаяся к транскрибации конференции.
Атрибуция — к `conference_participants` (ADR-002), а не к `users`: гость
без `user_id` проходит пайплайн наравне с зарегистрированным пользователем.
"""
__tablename__ = "phrases"
__table_args__ = (Index("ix_phrases_session_id_t_start", "session_id", "t_start"),)
id: Mapped[int] = mapped_column(BigInteger, Identity(always=True), primary_key=True)
participant_id: Mapped[uuid.UUID] = mapped_column(
UUID(as_uuid=True),
ForeignKey("conference_participants.id", ondelete="CASCADE"),
nullable=False,
)
session_id: Mapped[uuid.UUID] = mapped_column(
UUID(as_uuid=True),
ForeignKey("conference_sessions.id", ondelete="CASCADE"),
nullable=False,
)
data: Mapped[str] = mapped_column(Text, nullable=False)
t_start: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False)
t_end: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False)