commit
9c5fef1a4d
412 files changed
+94582
No files matched your search
@@ -0,0 +1,33 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from sqlalchemy import Float, ForeignKey, Index, Integer, String, Text, UniqueConstraint
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from sakura_cloud.db.base import Base
|
||||
from sakura_cloud.models.mixins import TimestampMixin, UUIDPrimaryKeyMixin
|
||||
|
||||
|
||||
class ArtworkOcrText(UUIDPrimaryKeyMixin, TimestampMixin, Base):
|
||||
__tablename__ = "artwork_ocr_texts"
|
||||
__table_args__ = (
|
||||
UniqueConstraint("user_id", "artwork_id", name="uq_artwork_ocr_texts_user_artwork"),
|
||||
Index("ix_artwork_ocr_texts_user_artwork", "user_id", "artwork_id"),
|
||||
Index("ix_artwork_ocr_texts_user_status", "user_id", "status"),
|
||||
Index("ix_artwork_ocr_texts_user_source", "user_id", "source_platform", "source_id"),
|
||||
)
|
||||
|
||||
user_id: Mapped[str] = mapped_column(String(36), ForeignKey("users.id", ondelete="CASCADE"), nullable=False)
|
||||
artwork_id: Mapped[str] = mapped_column(String(36), ForeignKey("artworks.id", ondelete="CASCADE"), nullable=False)
|
||||
file_id: Mapped[str | None] = mapped_column(String(36), ForeignKey("user_files.id", ondelete="SET NULL"), nullable=True)
|
||||
source_platform: Mapped[str | None] = mapped_column(String(20), nullable=True)
|
||||
source_id: Mapped[str | None] = mapped_column(String(50), nullable=True)
|
||||
language: Mapped[str] = mapped_column(String(20), default="mixed", nullable=False)
|
||||
ocr_text: Mapped[str] = mapped_column(Text, default="", nullable=False)
|
||||
confidence: Mapped[float | None] = mapped_column(Float, nullable=True)
|
||||
engine: Mapped[str] = mapped_column(String(50), default="paddleocr", nullable=False)
|
||||
status: Mapped[str] = mapped_column(String(20), default="pending", nullable=False, index=True)
|
||||
attempts: Mapped[int] = mapped_column(Integer, default=0, nullable=False)
|
||||
error: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
|
||||
artwork = relationship("Artwork", back_populates="ocr_text")
|
||||
user = relationship("User", back_populates="artwork_ocr_texts")
|
||||
Reference in new issue
Block a user