from fastapi import APIRouter, BackgroundTasks from app.scheduler.cron import run_daily_tech_digest_pipeline router = APIRouter() @router.post("") async def trigger_manual_scrape(background_tasks: BackgroundTasks): """ Manually triggers the tech update scraping, LangChain AI summarization, ChromaDB indexing, and FCM push notification pipeline. Runs asynchronously in background tasks. """ background_tasks.add_task(run_daily_tech_digest_pipeline) return { "status": "triggered", "message": "Daily tech update pipeline started in background. Check /api/v1/digests/latest shortly." } @router.post("/sync") async def trigger_manual_scrape_sync(): """ Synchronously triggers the pipeline and returns the result immediately. """ result = await run_daily_tech_digest_pipeline() return result