Интегрирован wesp в сайт
CI / quality (push) Canceled after 0s

This commit is contained in:
влад
2026-07-17 12:57:18 +03:00
parent 5dfa06ddbe
commit 355c0ef9f1
883 changed files with 194576 additions and 177 deletions
+28
View File
@@ -0,0 +1,28 @@
"""Канонические indicator_key для нутриентов компонента (без fuzzy-match)."""
from __future__ import annotations
from typing import Any
from app.lab.norm_catalog import NORM_HEADER_TO_KEY
def augment_with_indicator_keys(data: dict[str, Any] | None) -> dict[str, float]:
"""Дублирует значения под slug indicator_key."""
if not data:
return {}
out: dict[str, float] = {}
for raw_key, raw_val in data.items():
try:
out[str(raw_key)] = float(raw_val)
except (TypeError, ValueError):
continue
for header, indicator_key in NORM_HEADER_TO_KEY.items():
if header in out and indicator_key not in out:
out[indicator_key] = out[header]
return out
def canonicalize_for_storage(data: dict[str, Any] | None) -> dict[str, float]:
"""При записи в EAV: slug indicator_key + исходный заголовок."""
return augment_with_indicator_keys(data)