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:
@@ -268,4 +268,10 @@ async def run_agent(
|
||||
logger.exception("Failed to save AgentRun for %s", agent.id)
|
||||
result_data["save_error"] = str(e)
|
||||
|
||||
return result_data
|
||||
return result_data
|
||||
|
||||
|
||||
# Register all job functions with the job registry
|
||||
from app.core.job_registry import register_job
|
||||
|
||||
register_job("run_agent", run_agent)
|
||||
@@ -277,3 +277,9 @@ async def run_automation(
|
||||
result_data["save_error"] = str(e)
|
||||
|
||||
return result_data
|
||||
|
||||
|
||||
# Register all job functions with the job registry
|
||||
from app.core.job_registry import register_job
|
||||
|
||||
register_job("run_automation", run_automation)
|
||||
|
||||
@@ -181,7 +181,8 @@ async def list_miniapps(
|
||||
"""List custom MiniApps from plugin config."""
|
||||
from app.plugins.builtins.kommunikation.miniapp_registry import MiniAppRegistry
|
||||
registry = MiniAppRegistry()
|
||||
return registry.list_apps()
|
||||
items = registry.list_apps()
|
||||
return {"items": items, "total": len(items)}
|
||||
|
||||
|
||||
@router.post(
|
||||
|
||||
@@ -71,3 +71,9 @@ async def scheduler_tick(ctx: dict[str, Any]) -> None:
|
||||
|
||||
except Exception:
|
||||
logger.exception("Failed to process cron job %s", job.id)
|
||||
|
||||
|
||||
# Register all job functions with the job registry
|
||||
from app.core.job_registry import register_job
|
||||
|
||||
register_job("scheduler_tick", scheduler_tick)
|
||||
|
||||
@@ -80,3 +80,9 @@ async def check_workflow_timeouts(ctx: dict[str, Any]) -> None:
|
||||
|
||||
except Exception:
|
||||
logger.exception("Failed to process timeout for instance %s", inst.id)
|
||||
|
||||
|
||||
# Register all job functions with the job registry
|
||||
from app.core.job_registry import register_job
|
||||
|
||||
register_job("check_workflow_timeouts", check_workflow_timeouts)
|
||||
|
||||
Reference in New Issue
Block a user