refactor(db)!: clean up business SQL access
- make realtime replacement and analysis result writes transactional\n- consolidate SCADA repositories and remove process-global project state\n- validate SCADA batches and use indexed GIS-backed business queries\n\nBREAKING CHANGE: remove the public analysis result writer and the pipeline-health network_name query parameter.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from datetime import datetime
|
||||
from uuid import UUID
|
||||
|
||||
from fastapi import APIRouter, Body, Depends, HTTPException, Path, Query
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
from psycopg import AsyncConnection
|
||||
|
||||
from app.infra.db.timescaledb.repositories.analysis import AnalysisResultsRepository
|
||||
@@ -11,27 +11,6 @@ from .dependencies import get_timescale_connection
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.post("/timeseries/analysis/runs/{run_id}/results", status_code=201)
|
||||
async def store_analysis_results(
|
||||
run_id: UUID = Path(..., description="分析运行 ID"),
|
||||
payload: dict = Body(...),
|
||||
conn: AsyncConnection = Depends(get_timescale_connection),
|
||||
):
|
||||
try:
|
||||
node_rows = payload.get("node_results", [])
|
||||
link_rows = payload.get("link_results", [])
|
||||
await AnalysisResultsRepository.store_results(
|
||||
conn, run_id, node_rows, link_rows
|
||||
)
|
||||
return {
|
||||
"run_id": run_id,
|
||||
"node_count": len(node_rows),
|
||||
"link_count": len(link_rows),
|
||||
}
|
||||
except ValueError as exc:
|
||||
raise HTTPException(status_code=409, detail=str(exc)) from exc
|
||||
|
||||
|
||||
@router.get("/timeseries/analysis/runs/{run_id}/nodes/{node_id}")
|
||||
async def get_analysis_node_series(
|
||||
run_id: UUID,
|
||||
|
||||
Reference in New Issue
Block a user