| from fastapi import APIRouter, Form, UploadFile, File, Depends, HTTPException |
| from typing import Optional |
| from uuid import UUID |
| from datetime import date |
|
|
| from app.dependencies import require_linked_account |
| from app.stat_import.schemas import StatImportJobResponse, ImportReviewSchema, FinalizeImportRequest |
|
|
| router = APIRouter() |
|
|
| @router.post("/upload", response_model=StatImportJobResponse, summary="Upload a stat sheet (PDF/Image)") |
| async def upload_stat_sheet( |
| team_id: UUID = Form(...), |
| game_date: Optional[date] = Form(None), |
| opponent_name: Optional[str] = Form(None), |
| notes: Optional[str] = Form(None), |
| file: UploadFile = File(...), |
| account_info: dict = Depends(require_linked_account) |
| ): |
| """ |
| Coach uploads a PDF/image stat sheet. |
| System stores it in Supabase Storage and creates an import job. |
| """ |
| |
| |
| |
| raise HTTPException(status_code=501, detail="Not Implemented") |
|
|
|
|
| @router.post("/process/{import_job_id}", summary="Process an uploaded stat sheet") |
| async def process_stat_sheet(import_job_id: UUID, account_info: dict = Depends(require_linked_account)): |
| """ |
| Trigger the asynchronous or synchronous OCR parsing pipeline for this upload. |
| Classification -> Extraction -> Parsing -> Matching -> Validation. |
| """ |
| |
| raise HTTPException(status_code=501, detail="Not Implemented") |
|
|
|
|
| @router.get("/{import_job_id}", summary="Get import job details") |
| async def get_import_job(import_job_id: UUID, account_info: dict = Depends(require_linked_account)): |
| """ |
| Fetches the result of the pipeline: parsed data, status, etc. |
| """ |
| raise HTTPException(status_code=501, detail="Not Implemented") |
|
|
|
|
| @router.post("/{import_job_id}/confirm", summary="Acknowledge overrides on review flow") |
| async def confirm_review_edits(import_job_id: UUID, account_info: dict = Depends(require_linked_account)): |
| """ |
| Called periodically or as checkpoints when resolving unmatched players manually. |
| """ |
| raise HTTPException(status_code=501, detail="Not Implemented") |
|
|
|
|
| @router.get("/{import_job_id}/issues", response_model=ImportReviewSchema, summary="Get extraction or validation issues") |
| async def get_import_issues(import_job_id: UUID, account_info: dict = Depends(require_linked_account)): |
| """ |
| Return all validation and matching errors flagged during processing. |
| """ |
| raise HTTPException(status_code=501, detail="Not Implemented") |
|
|
|
|
| @router.post("/{import_job_id}/finalize", summary="Commit the checked stat sheet to the database") |
| async def finalize_stat_import( |
| import_job_id: UUID, |
| payload: FinalizeImportRequest, |
| account_info: dict = Depends(require_linked_account) |
| ): |
| """ |
| Saves final JSON mapped data into games, game_player_stats, game_team_totals tables. |
| Also triggers analytics event generation. |
| """ |
| |
| |
| |
| raise HTTPException(status_code=501, detail="Not Implemented") |
|
|