feat(phase5.1+6): fallback material cleanup + notification batch refactor
Phase 5.1 — MATERIAL_PALETTE removal:
- Remove MATERIAL_PALETTE + _material_to_color() from step_processor.py
- build_part_colors() now returns {part→material_name} for Blender resolver
Phase 6 — Notification Center Refactor:
- Migration 051: add channel (activity|notification|alert) to audit_log,
add frequency (immediate|daily|never) to notification_configs
- Three notification channels: activity (per-render), notification (batch
order summaries), alert (admin infrastructure)
- Per-render emit_notification_sync calls demoted to channel=activity
- New emit_batch_render_notification_sync(): single summary notification
when all order lines reach terminal state ("47/50 succeeded, 3 failed")
- Beat task batch_render_notifications every 60s: safety-net for missed
batch notifications after order completion
- GET /notifications: defaults to channel IN (notification, alert);
accepts ?channel=activity for activity feed
- Unread count badge counts only notification+alert channels
- Notifications.tsx: three tabs (Notifications | Activity | Alerts)
- NotificationSettings.tsx: frequency dropdown per event type
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,17 @@
|
||||
# Compat shim — use app.domains.notifications.service instead
|
||||
from app.domains.notifications.service import emit_notification, emit_notification_sync
|
||||
__all__ = ["emit_notification", "emit_notification_sync"]
|
||||
from app.domains.notifications.service import (
|
||||
emit_notification,
|
||||
emit_notification_sync,
|
||||
emit_batch_render_notification_sync,
|
||||
CHANNEL_ACTIVITY,
|
||||
CHANNEL_NOTIFICATION,
|
||||
CHANNEL_ALERT,
|
||||
)
|
||||
__all__ = [
|
||||
"emit_notification",
|
||||
"emit_notification_sync",
|
||||
"emit_batch_render_notification_sync",
|
||||
"CHANNEL_ACTIVITY",
|
||||
"CHANNEL_NOTIFICATION",
|
||||
"CHANNEL_ALERT",
|
||||
]
|
||||
|
||||
@@ -16,40 +16,29 @@ if TYPE_CHECKING:
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
MATERIAL_PALETTE = [
|
||||
"#4C9BE8", "#E85B4C", "#4CBE72", "#E8A84C", "#A04CE8",
|
||||
"#4CD4E8", "#E84CA8", "#7EC850", "#E86B30", "#5088C8",
|
||||
]
|
||||
|
||||
|
||||
def _material_to_color(material_name: str | None, index: int) -> str:
|
||||
"""Return a deterministic hex color: hash material name, or use palette by index."""
|
||||
if material_name and material_name.strip():
|
||||
i = abs(hash(material_name.strip().lower())) % len(MATERIAL_PALETTE)
|
||||
return MATERIAL_PALETTE[i]
|
||||
return MATERIAL_PALETTE[index % len(MATERIAL_PALETTE)]
|
||||
|
||||
|
||||
def build_part_colors(
|
||||
cad_parsed_objects: list[str],
|
||||
cad_part_materials: list[dict],
|
||||
) -> dict[str, str]:
|
||||
"""
|
||||
Build {part_name: hex_color} for thumbnail rendering.
|
||||
Build {part_name: material_name} for Blender rendering.
|
||||
|
||||
Returns a mapping of part name → Schaeffler material name (e.g. SCHAEFFLER_010101_Steel-Bare).
|
||||
Parts with no material assignment are omitted; Blender will use the fallback material
|
||||
(SCHAEFFLER_059999_FailedMaterial) for unrecognised parts.
|
||||
|
||||
Args:
|
||||
cad_parsed_objects: List of part names from cad_file.parsed_objects["objects"].
|
||||
cad_part_materials: List of {part_name, material} dicts from order_item.cad_part_materials.
|
||||
"""
|
||||
mat_map = {
|
||||
m["part_name"].lower(): m.get("material")
|
||||
for m in cad_part_materials
|
||||
if m.get("part_name")
|
||||
}
|
||||
return {
|
||||
name: _material_to_color(mat_map.get(name.lower()), i)
|
||||
for i, name in enumerate(cad_parsed_objects)
|
||||
}
|
||||
result = {}
|
||||
for m in cad_part_materials:
|
||||
part = m.get("part_name", "").strip()
|
||||
material = m.get("material", "").strip()
|
||||
if part and material:
|
||||
result[part] = material
|
||||
return result
|
||||
|
||||
|
||||
def _normalize_stem(name: str) -> str:
|
||||
|
||||
Reference in New Issue
Block a user