from __future__ import annotations
from fastapi import APIRouter
from fastapi.responses import RedirectResponse
from app.sync2.pipeline import apply_decisions

router = APIRouter()

@router.post("/sync/batch/{batch_id}/apply", response_class=RedirectResponse)
@router.post("/sync/apply/{batch_id}", response_class=RedirectResponse)
async def sync_apply_batch(batch_id: str):
    apply_decisions(batch_id)
    return RedirectResponse(url=f"/sync/batch/{batch_id}?applied=1", status_code=303)
