Files
POPS/alembic/versions/0007_stl_cache.py
Martin Hohenberg 4c7acb1c52 Analyse STL/3MF on upload: bounding box + volume, cached in stl_cache
- StlCache model: filename, cube_x/y/z (mm), volume_ccm
- Migration 0007: stl_cache table
- app/stl_analysis.py: trimesh-based analyse() + get_cache_map()
  - Runs immediately after upload in both /jobs and /brackets/{id}/jobs
  - Skips .gcode (no geometry), caches per filename, idempotent
- Library selector in both modals now shows dimensions and volume
- requirements: trimesh==4.5.3

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-18 22:04:11 +02:00

36 lines
1.0 KiB
Python

"""stl_cache table for bounding box and volume
Revision ID: 0007
Revises: 0006
Create Date: 2026-06-18
"""
from typing import Sequence, Union
import sqlalchemy as sa
from alembic import op
revision: str = "0007"
down_revision: Union[str, None] = "0006"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
op.create_table(
"stl_cache",
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
sa.Column("filename", sa.String(255), nullable=False),
sa.Column("cube_x", sa.Float(), nullable=True),
sa.Column("cube_y", sa.Float(), nullable=True),
sa.Column("cube_z", sa.Float(), nullable=True),
sa.Column("volume_ccm", sa.Float(), nullable=True),
sa.Column("created_at", sa.DateTime(), nullable=False, server_default=sa.text("CURRENT_TIMESTAMP")),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("filename"),
)
def downgrade() -> None:
op.drop_table("stl_cache")