Show norm cost breakdown and reference rates in finder

This commit is contained in:
anor
2026-12-04 22:51:01 +10:00
parent 4bb95e757f
commit 011c57df9e
9 changed files with 261 additions and 39 deletions
+6 -4
View File
@@ -555,7 +555,7 @@ MAX_MESSAGE_LEN = 10_000
# ⚠️ Версия UI — единый источник. БАМПАТЬ ПРИ КАЖДОМ ДЕПЛОЕ (формат: YYYY-MM-DD + буква).
# Фронт берёт её через GET /api/version (chat.html + admin.html, элемент .app-version).
APP_VERSION = "2026-12-04g"
APP_VERSION = "2026-12-04h"
# Audit: path → action name mapping
_AUDIT_MAP = [
@@ -2420,8 +2420,9 @@ async def norm_finder_catalog(request: Request):
sid = row.get("subject_id")
if isinstance(sid, int) and not isinstance(sid, bool):
subjects[sid] = row.get("subject_name") or f"Субъект {sid}"
return {"bases": bases, "subjects": [{"id": sid, "name": name}
for sid, name in sorted(subjects.items(), key=lambda x: x[1])]}
return {"bases": bases, "rates": await asyncio.to_thread(norm_finder.rate_catalog),
"subjects": [{"id": sid, "name": name}
for sid, name in sorted(subjects.items(), key=lambda x: x[1])]}
_public_finder_rate: dict[str, list[float]] = {}
@@ -2449,7 +2450,8 @@ def _check_public_finder_rate(request: Request) -> None:
async def public_norm_finder_catalog(request: Request):
_check_public_finder_rate(request)
import norm_finder
return {"bases": await asyncio.to_thread(norm_finder.catalog)}
return {"bases": await asyncio.to_thread(norm_finder.catalog),
"rates": await asyncio.to_thread(norm_finder.rate_catalog)}
@app.get("/api/public/norm-finder/browse")