|
@@ -641,6 +641,17 @@ async def varv_calib_set(payload: dict = Body(...)) -> dict:
|
|
|
)
|
|
)
|
|
|
if not rows:
|
|
if not rows:
|
|
|
raise HTTPException(status_code=409, detail="Mõõtmisi pole")
|
|
raise HTTPException(status_code=409, detail="Mõõtmisi pole")
|
|
|
|
|
+ # Stabiilsuse kontroll: viimased mõõtmised peavad olema samast olekust.
|
|
|
|
|
+ totals = [
|
|
|
|
|
+ sum(float(r[b]) for b in VARV_BANDS if r.get(b) is not None)
|
|
|
|
|
+ for r in rows
|
|
|
|
|
+ ]
|
|
|
|
|
+ tmax = max(totals) if totals else 0.0
|
|
|
|
|
+ if tmax > 0 and (tmax - min(totals)) / tmax > 0.2:
|
|
|
|
|
+ raise HTTPException(
|
|
|
|
|
+ status_code=422,
|
|
|
|
|
+ detail="Mõõtmine pole stabiliseerunud (viimased mõõtmised erinevad). Oota ~30 s pärast katmise/valge pinna muutust ja proovi uuesti.",
|
|
|
|
|
+ )
|
|
|
ref: dict[str, float] = {}
|
|
ref: dict[str, float] = {}
|
|
|
for f in VARV_CALIB_FIELDS:
|
|
for f in VARV_CALIB_FIELDS:
|
|
|
vals = [float(r[f]) for r in rows if r.get(f) is not None]
|
|
vals = [float(r[f]) for r in rows if r.get(f) is not None]
|