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:
@@ -0,0 +1,53 @@
|
||||
"""add_print_jobs.
|
||||
|
||||
Revision ID: c3d4e5f6g7h8
|
||||
Revises: b2c3d4e5f6g7
|
||||
Create Date: 2025-01-15 04:00:00.000000
|
||||
"""
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "c3d4e5f6g7h8"
|
||||
down_revision = "b2c3d4e5f6g7"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Create print_job table and add needs_weighing to spool."""
|
||||
# Create print_job table
|
||||
op.create_table(
|
||||
"print_job",
|
||||
sa.Column("id", sa.Integer(), nullable=False),
|
||||
sa.Column("spool_id", sa.Integer(), nullable=False),
|
||||
sa.Column("created", sa.DateTime(), nullable=False),
|
||||
sa.Column("finished", sa.DateTime(), nullable=True),
|
||||
sa.Column("filename", sa.String(length=256), nullable=False),
|
||||
sa.Column("filament_used_g", sa.Float(), nullable=False),
|
||||
sa.Column("filament_used_mm", sa.Float(), nullable=True),
|
||||
sa.Column("status", sa.String(length=16), nullable=False, server_default="pending"),
|
||||
sa.ForeignKeyConstraint(
|
||||
["spool_id"],
|
||||
["spool.id"],
|
||||
ondelete="CASCADE",
|
||||
),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
op.create_index(op.f("ix_print_job_id"), "print_job", ["id"], unique=False)
|
||||
op.create_index(op.f("ix_print_job_spool_id"), "print_job", ["spool_id"], unique=False)
|
||||
|
||||
# Add needs_weighing column to spool table
|
||||
op.add_column(
|
||||
"spool",
|
||||
sa.Column("needs_weighing", sa.Boolean(), nullable=True, server_default="0"),
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Drop print_job table and remove needs_weighing from spool."""
|
||||
op.drop_column("spool", "needs_weighing")
|
||||
op.drop_index(op.f("ix_print_job_spool_id"), table_name="print_job")
|
||||
op.drop_index(op.f("ix_print_job_id"), table_name="print_job")
|
||||
op.drop_table("print_job")
|
||||
Reference in New Issue
Block a user