rDrama/files/classes/volunteer_janitor.py
justcool393 e040ed6708 Upgrade to SQLAlchemy 2.0
This has exposed an interesting amount of bugs and stopped throwing type errors every 5 seconds

It's worth noting that not all models are fully typed, that is, we
have `Mapped[Any]` in some places where a narrower type would be nice.

Upgrading to SQLA2 we don't *need* this, but it is helpful and
makes error checking reliable.
2023-08-09 02:27:55 -05:00

32 lines
1,006 B
Python

from datetime import datetime
import enum
from sqlalchemy import *
from sqlalchemy.orm import Mapped, mapped_column, relationship
from files.classes.base import Base
class VolunteerJanitorResult(enum.Enum):
Pending = 0
TopQuality = 1
Good = 2
Neutral = 3
Bad = 4
Warning = 5
Ban = 6
class VolunteerJanitorRecord(Base):
__tablename__ = "volunteer_janitor"
id: Mapped[int] = mapped_column(Integer, primary_key=True)
user_id: Mapped[int] = mapped_column(Integer, ForeignKey("users.id"), nullable=False)
comment_id: Mapped[int] = mapped_column(Integer, ForeignKey("comments.id"), nullable=False)
recorded_utc: Mapped[datetime] = mapped_column(DateTime, default=0, nullable=False)
result: Mapped[VolunteerJanitorResult] = mapped_column(Enum(VolunteerJanitorResult), default=VolunteerJanitorResult.Pending, nullable=False)
Index('volunteer_comment_index', user_id, comment_id)
user = relationship("User")
comment = relationship("Comment")