fix UI 500 + slow backup with millions of processed_mails
- fix: Starlette 1.0 changed TemplateResponse signature — request is now the first positional argument, not nested inside the context dict. All HTML routes returned 500 (unhashable dict in jinja2 template cache) after the image rebuild picked up the new starlette version. - fix: processed_mails (1.7M rows in production: 1 account × 12 rules × 141k inbox mails) made backup export hit 558 MB / 90s. Moved to opt-in checkbox in the UI alongside the logs option, default off. - yield_per for streaming the processed_mails query when included. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -27,10 +27,18 @@ async def yaml_import(file: UploadFile, db: Session = Depends(get_db)):
|
||||
@router.get("/backup")
|
||||
def backup_export(
|
||||
include_logs: bool = Query(default=False),
|
||||
include_processed: bool = Query(default=False),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
content = export_backup(db, include_logs=include_logs)
|
||||
suffix = "-mit-logs" if include_logs else ""
|
||||
content = export_backup(
|
||||
db, include_logs=include_logs, include_processed=include_processed
|
||||
)
|
||||
suffix_parts = []
|
||||
if include_processed:
|
||||
suffix_parts.append("verarbeitung")
|
||||
if include_logs:
|
||||
suffix_parts.append("logs")
|
||||
suffix = ("-mit-" + "-".join(suffix_parts)) if suffix_parts else ""
|
||||
timestamp = datetime.utcnow().strftime("%Y%m%d-%H%M%S")
|
||||
filename = f"mailfilter-backup{suffix}-{timestamp}.json"
|
||||
return Response(
|
||||
|
||||
Reference in New Issue
Block a user