INNER CODE UNIT · Python

process_user_report

doganarif/fastapi-radar · example_app.py:337

async def process_user_report(user_id: int, background_tasks: BackgroundTasks):
    """Example endpoint that triggers a long-running background task."""
    background_tasks.add_task(process_report, user_id)
    return {"message": "Report processing started"}


@app.post("/generate-analytics")
async def generate_analytics_endpoint(
    background_tasks: BackgroundTasks, days: int = Query(7, ge=1, le=365)
):
    """Generate analytics for the specified number of days."""
    background_tasks.add_task(generate_analytics, days)
    return {"message": f"Analytics generation started for last {days} days"}


@app.post("/sync-inventory")
async def sync_inventory(background_tasks: BackgroundTasks):
    """Synchronize inventory (sync task example)."""

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…