perf: Fix all 7 code analysis issues

HIGH (Performance):
- Replace 8 sync file operations with aiofiles in async context (storage, mail,
  report_generator, dms_bridge, ai_assistant)
- Frontend bundle splitting: manualChunks for react-vendor, ui-components, tanstack,
  markdown, icons, utils, i18n (ui chunk 936K → ~19K)

MEDIUM (Architecture):
- Worker circular deps: Replace direct plugin imports with job_registry.py pattern
  (register_job/get_all_jobs, importlib-based lazy loading)
- App-wide ErrorBoundary: New ErrorBoundary.tsx component, wrapped in AppShell
  and all standalone routes

LOW (Code Quality):
- N+1 query fix: selectinload(Contact.contact_persons) in list_contacts()
- O(n²) dedup fix: SQL GROUP BY for email/phone duplicates, Dict-based name grouping
- Response format standardization: 7 routes converted from plain arrays to
  {items: [...], total: N} format
This commit is contained in:
Agent Zero
2026-07-25 09:19:32 +02:00
parent 224a71ba56
commit aaa7406929
26 changed files with 436 additions and 225 deletions
+2 -1
View File
@@ -27,7 +27,8 @@ async def list_folders(
"""List all contact folders for the current user."""
tenant_id = uuid.UUID(current_user["tenant_id"])
user_id = uuid.UUID(current_user["user_id"])
return await contact_folder_service.list_folders(db, tenant_id, user_id)
items = await contact_folder_service.list_folders(db, tenant_id, user_id)
return {"items": items, "total": len(items)}
@router.post("", status_code=status.HTTP_201_CREATED)
+2 -1
View File
@@ -170,7 +170,8 @@ async def list_contact_persons(
):
"""List all contact persons for a contact."""
tenant_id = uuid.UUID(current_user["tenant_id"])
return await contact_service.list_contact_persons(db, tenant_id, contact_id)
items = await contact_service.list_contact_persons(db, tenant_id, contact_id)
return {"items": items, "total": len(items)}
@router.post("/{contact_id}/persons", status_code=status.HTTP_201_CREATED)