a70cb55d01
- workflow_builder.py: fix broken stubs, add render_order_line_still_task
(resolves step_path from DB instead of passing order_line_id as step_path)
- domains/rendering/tasks.py: add render_order_line_still_task,
export_gltf_for_order_line_task, export_blend_for_order_line_task,
generate_gltf_geometry_task (trimesh STL→GLB, no Blender needed)
- tasks/step_tasks.py: add generate_gltf_geometry_task for CadFile GLB export
- cad router: POST /{id}/generate-gltf-geometry endpoint (admin/PM)
- worker router: GET /celery-workers + POST /scale (docker compose subprocess)
- Dockerfile: pip install -e "[dev]" to enable pytest
- docker-compose.yml: docker socket + compose file mount on backend
- ThreeDViewer.tsx: mode toggle (geometry/production), wireframe, env presets,
download buttons (GLB + .blend)
- CadPreview.tsx: load gltf_geometry/gltf_production/blend_production assets
from MediaAsset table and pass URLs to ThreeDViewer
- ProductDetail.tsx: "View 3D" button → /cad/:id, "Generate GLB" button
- media router/service: cad_file_id filter on GET /api/media
- WorkerManagement.tsx: new page with worker status, queue depth, scale controls
- App.tsx + Layout.tsx: /workers route + sidebar link (admin/PM)
- tests: test_rendering_service.py, test_orders_service.py (backend)
- tests: WorkerActivity.test.tsx, WorkerManagement.test.tsx (frontend)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
72 lines
2.3 KiB
Python
72 lines
2.3 KiB
Python
"""MediaAsset service."""
|
|
import uuid
|
|
from sqlalchemy import select, update as sql_update
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
from app.domains.media.models import MediaAsset, MediaAssetType
|
|
|
|
|
|
async def list_media_assets(
|
|
db: AsyncSession,
|
|
product_id: uuid.UUID | None = None,
|
|
order_line_id: uuid.UUID | None = None,
|
|
cad_file_id: uuid.UUID | None = None,
|
|
asset_type: MediaAssetType | None = None,
|
|
is_archived: bool | None = False,
|
|
skip: int = 0,
|
|
limit: int = 50,
|
|
) -> list[MediaAsset]:
|
|
q = select(MediaAsset).order_by(MediaAsset.created_at.desc())
|
|
if product_id:
|
|
q = q.where(MediaAsset.product_id == product_id)
|
|
if order_line_id:
|
|
q = q.where(MediaAsset.order_line_id == order_line_id)
|
|
if cad_file_id:
|
|
q = q.where(MediaAsset.cad_file_id == cad_file_id)
|
|
if asset_type:
|
|
q = q.where(MediaAsset.asset_type == asset_type)
|
|
if is_archived is not None:
|
|
q = q.where(MediaAsset.is_archived == is_archived)
|
|
q = q.offset(skip).limit(limit)
|
|
result = await db.execute(q)
|
|
return list(result.scalars().all())
|
|
|
|
|
|
async def get_media_asset(db: AsyncSession, asset_id: uuid.UUID) -> MediaAsset | None:
|
|
result = await db.execute(select(MediaAsset).where(MediaAsset.id == asset_id))
|
|
return result.scalar_one_or_none()
|
|
|
|
|
|
async def create_media_asset(db: AsyncSession, **kwargs) -> MediaAsset:
|
|
asset = MediaAsset(**kwargs)
|
|
db.add(asset)
|
|
await db.commit()
|
|
await db.refresh(asset)
|
|
return asset
|
|
|
|
|
|
async def archive_media_asset(db: AsyncSession, asset_id: uuid.UUID) -> MediaAsset | None:
|
|
await db.execute(
|
|
sql_update(MediaAsset).where(MediaAsset.id == asset_id).values(is_archived=True)
|
|
)
|
|
await db.commit()
|
|
return await get_media_asset(db, asset_id)
|
|
|
|
|
|
async def delete_media_asset(db: AsyncSession, asset_id: uuid.UUID) -> bool:
|
|
asset = await get_media_asset(db, asset_id)
|
|
if not asset:
|
|
return False
|
|
await db.delete(asset)
|
|
await db.commit()
|
|
return True
|
|
|
|
|
|
def get_download_url(asset: MediaAsset) -> str | None:
|
|
"""Get presigned URL from MinIO or local path."""
|
|
try:
|
|
from app.core.storage import get_storage
|
|
storage = get_storage()
|
|
return storage.get_url(asset.storage_key)
|
|
except Exception:
|
|
return f"/uploads/{asset.storage_key}"
|