INNER CODE UNIT · Python
generate_analytics_endpoint
doganarif/fastapi-radar · example_app.py:344
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)."""
background_tasks.add_task(sync_inventory_task)
return {"message": "Inventory sync started"}
@app.post("/test-failure")
async def test_task_failure(background_tasks: BackgroundTasks):
"""Test a failing background task."""