feat: per-position camera settings, material alias dialog, product delete, media browser links
- Per-render-position focal_length_mm/sensor_width_mm (DB → pipeline → Blender)
- FOV-based camera distance with min clamp fix for wide-angle lenses
- Unmapped materials blocking dialog on "Dispatch Renders" with batch alias creation
- Material check endpoint (GET /orders/{id}/check-materials)
- Batch alias endpoint (POST /materials/batch-aliases)
- Quick-map "No alias" badges on Materials page
- Full product hard-delete with storage cleanup (MinIO + disk files + orphaned CadFile)
- Delete button on ProductDetail page with confirmation
- Clickable product names in Media Browser (links to product page)
- Single-line render dispatch/retry (POST /orders/{id}/lines/{id}/dispatch-render)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,7 @@ Resolution chain:
|
||||
3. Pass through unchanged → Blender will show FailedMaterial magenta
|
||||
"""
|
||||
import logging
|
||||
from difflib import SequenceMatcher
|
||||
|
||||
from sqlalchemy import create_engine, select, func
|
||||
from sqlalchemy.orm import Session, selectinload
|
||||
@@ -138,3 +139,66 @@ async def seed_material_aliases_from_mappings(
|
||||
await db.flush()
|
||||
|
||||
return {"created": created, "skipped": skipped}
|
||||
|
||||
|
||||
async def find_unmapped_materials(
|
||||
material_names: list[str], db: AsyncSession
|
||||
) -> list[dict]:
|
||||
"""Find material names that have no alias or library match.
|
||||
|
||||
Returns a list of {"raw_name": str, "suggestions": [...]} for each
|
||||
unmapped name. Suggestions are the top 5 SCHAEFFLER library materials
|
||||
by string similarity.
|
||||
"""
|
||||
if not material_names:
|
||||
return []
|
||||
|
||||
# Load all aliases (case-insensitive lookup)
|
||||
alias_rows = (await db.execute(select(MaterialAlias))).scalars().all()
|
||||
alias_set: set[str] = {a.alias.lower() for a in alias_rows}
|
||||
|
||||
# Load all materials
|
||||
mat_rows = (await db.execute(select(Material))).scalars().all()
|
||||
# Library materials have a schaeffler_code
|
||||
library_mats = [m for m in mat_rows if m.schaeffler_code is not None]
|
||||
# All material names (case-insensitive) for exact-match check
|
||||
name_lookup: dict[str, Material] = {m.name.lower(): m for m in mat_rows}
|
||||
|
||||
unmapped: list[dict] = []
|
||||
seen: set[str] = set()
|
||||
|
||||
for raw_name in material_names:
|
||||
raw_lower = raw_name.lower()
|
||||
if raw_lower in seen:
|
||||
continue
|
||||
seen.add(raw_lower)
|
||||
|
||||
# 1. Alias match → mapped
|
||||
if raw_lower in alias_set:
|
||||
continue
|
||||
|
||||
# 2. Exact name match with a library material → mapped
|
||||
matched_mat = name_lookup.get(raw_lower)
|
||||
if matched_mat and matched_mat.schaeffler_code is not None:
|
||||
continue
|
||||
|
||||
# Unmapped — compute suggestions from library materials
|
||||
scored = []
|
||||
for lib_mat in library_mats:
|
||||
ratio = SequenceMatcher(None, raw_lower, lib_mat.name.lower()).ratio()
|
||||
if ratio > 0.3:
|
||||
scored.append((ratio, lib_mat))
|
||||
scored.sort(key=lambda x: x[0], reverse=True)
|
||||
|
||||
suggestions = [
|
||||
{
|
||||
"id": str(m.id),
|
||||
"name": m.name,
|
||||
"schaeffler_code": str(m.schaeffler_code),
|
||||
}
|
||||
for _, m in scored[:5]
|
||||
]
|
||||
|
||||
unmapped.append({"raw_name": raw_name, "suggestions": suggestions})
|
||||
|
||||
return unmapped
|
||||
|
||||
Reference in New Issue
Block a user