PaperParser/app/models/task.py

28 lines
1.0 KiB
Python
Raw Permalink Normal View History

2024-02-03 22:02:10 +10:00
import datetime
from sqlalchemy import Integer, DateTime
2024-01-31 19:37:01 +10:00
from sqlalchemy.schema import Column, ForeignKey
from sqlalchemy.orm import Mapped, mapped_column, relationship
from app.extensions import db
2024-02-25 00:11:48 +10:00
from app.models.collection import Collection
2024-01-31 19:37:01 +10:00
class Task(db.Model):
id: Mapped[int] = mapped_column(primary_key=True)
task_id: Mapped[str] = mapped_column(nullable=True)
name: Mapped[str] = mapped_column(unique=True)
session_id = Column(Integer, ForeignKey("session.id"))
session: Mapped['Session'] = relationship("Session", back_populates="tasks")
2024-02-24 22:34:54 +10:00
collection_id = Column(Integer, ForeignKey("collection.id"))
2024-02-25 00:11:48 +10:00
collection: Mapped['Collection'] = relationship('Collection', back_populates='tasks')
2024-02-24 22:34:54 +10:00
datetime: Mapped[DateTime] = Column(DateTime, default=datetime.datetime.utcnow())
2024-01-31 19:37:01 +10:00
status: Mapped[str]
status_message: Mapped[str]
type: Mapped[str]
url: Mapped[str] = mapped_column(nullable=True)
message: Mapped[str] = mapped_column(nullable=True)
file: Mapped[str] = mapped_column(nullable=True)