Add Print Job tracking for slicer integration
Backend for tracking print jobs from Elegoo/Orca Slicer: - PrintJob model: tracks pending/completed/cancelled jobs - API endpoints: create, list, complete, cancel jobs - needs_weighing flag on Spool: for cancelled print recalibration - Database migration for new table and column Workflow: 1. Slicer post-processing script creates pending job 2. User completes job → auto-deducts filament 3. User cancels job → flags spool for manual weigh-in Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -80,6 +80,10 @@ class Spool(Base):
|
||||
lot_nr: Mapped[Optional[str]] = mapped_column(String(64))
|
||||
comment: Mapped[Optional[str]] = mapped_column(String(1024))
|
||||
archived: Mapped[Optional[bool]] = mapped_column()
|
||||
needs_weighing: Mapped[Optional[bool]] = mapped_column(
|
||||
default=False,
|
||||
comment="Flag indicating spool needs manual weigh-in (e.g., after cancelled print).",
|
||||
)
|
||||
extra: Mapped[list["SpoolField"]] = relationship(
|
||||
back_populates="spool",
|
||||
cascade="save-update, merge, delete, delete-orphan",
|
||||
@@ -106,6 +110,26 @@ class SpoolAdjustment(Base):
|
||||
comment: Mapped[Optional[str]] = mapped_column(String(256), comment="Optional user comment.")
|
||||
|
||||
|
||||
class PrintJob(Base):
|
||||
"""Track pending/completed print jobs from slicer."""
|
||||
|
||||
__tablename__ = "print_job"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True, index=True)
|
||||
spool_id: Mapped[int] = mapped_column(ForeignKey("spool.id", ondelete="CASCADE"), index=True)
|
||||
spool: Mapped["Spool"] = relationship()
|
||||
created: Mapped[datetime] = mapped_column(comment="When the job was created (slice time).")
|
||||
finished: Mapped[Optional[datetime]] = mapped_column(comment="When the job was completed/cancelled.")
|
||||
filename: Mapped[str] = mapped_column(String(256), comment="G-code filename.")
|
||||
filament_used_g: Mapped[float] = mapped_column(comment="Estimated filament usage in grams.")
|
||||
filament_used_mm: Mapped[Optional[float]] = mapped_column(comment="Estimated filament usage in mm.")
|
||||
status: Mapped[str] = mapped_column(
|
||||
String(16),
|
||||
default="pending",
|
||||
comment="Status: 'pending', 'completed', 'cancelled'.",
|
||||
)
|
||||
|
||||
|
||||
class Setting(Base):
|
||||
__tablename__ = "setting"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user