Add detail job storage
This commit is contained in:
@@ -57,6 +57,7 @@ class Car(Base):
|
||||
last_seen_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False, default=func.now(), index=True)
|
||||
sold_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True, index=True)
|
||||
details_fetched_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True, index=True)
|
||||
gallery_fetched_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True, index=True)
|
||||
images: Mapped[list["Image"]] = relationship("Image", back_populates="car", cascade="all, delete-orphan")
|
||||
|
||||
|
||||
@@ -70,6 +71,33 @@ class Image(Base):
|
||||
car: Mapped[Car] = relationship("Car", back_populates="images")
|
||||
|
||||
|
||||
class DetailJob(Base):
|
||||
__tablename__ = "MOBILEDE_detail_jobs"
|
||||
__table_args__ = (
|
||||
Index("ix_MOBILEDE_detail_jobs_ready", "status", "available_at", "priority", "created_at"),
|
||||
Index("ix_MOBILEDE_detail_jobs_lease", "status", "lease_expires_at"),
|
||||
)
|
||||
id: Mapped[int] = mapped_column(BigInteger().with_variant(Integer, "sqlite"), primary_key=True, autoincrement=True)
|
||||
car_id: Mapped[int] = mapped_column(
|
||||
BigInteger().with_variant(Integer, "sqlite"),
|
||||
ForeignKey("MOBILEDE_cars.id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
unique=True,
|
||||
)
|
||||
listing_id: Mapped[str] = mapped_column(String(128), nullable=False, unique=True, index=True)
|
||||
status: Mapped[str] = mapped_column(String(32), nullable=False, default="pending", index=True)
|
||||
priority: Mapped[int] = mapped_column(Integer, nullable=False, default=3)
|
||||
attempts: Mapped[int] = mapped_column(Integer, nullable=False, default=0)
|
||||
available_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False, default=func.now(), index=True)
|
||||
lease_owner: Mapped[str | None] = mapped_column(String(64), nullable=True)
|
||||
lease_expires_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True, index=True)
|
||||
last_http_status: Mapped[int | None] = mapped_column(Integer, nullable=True)
|
||||
error_kind: Mapped[str | None] = mapped_column(String(64), nullable=True)
|
||||
last_error: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False, default=func.now())
|
||||
updated_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False, default=func.now(), onupdate=func.now())
|
||||
|
||||
|
||||
class SyncRun(Base):
|
||||
__tablename__ = "MOBILEDE_sync_runs"
|
||||
id: Mapped[int] = mapped_column(BigInteger().with_variant(Integer, "sqlite"), primary_key=True, autoincrement=True)
|
||||
|
||||
Reference in New Issue
Block a user