Initial project import
This commit is contained in:
@@ -2202,7 +2202,16 @@ def section_record_semantic_properties(row: dict[str, Any], parameters: list[dic
|
||||
mapped: set[int] = set()
|
||||
for index, (group, name) in SECTION_RECORD_SEMANTIC_PROPERTIES.items():
|
||||
mapped.add(index)
|
||||
add_grouped_property(groups, group, semantic_property(name, parameter_value(parameters, index), index=index))
|
||||
value = parameter_value(parameters, index)
|
||||
source = "form_payload"
|
||||
# A managed-form record can store the localized title outside its
|
||||
# direct parameter #3. The row decoder already resolves that exact
|
||||
# title path, so expose it instead of misleading an agent with an
|
||||
# empty semantic «Заголовок» beside a non-empty public row.title.
|
||||
if index == 3 and value in {None, ""} and row.get("title") not in {None, ""}:
|
||||
value = row.get("title")
|
||||
source = "form_payload_title_path"
|
||||
add_grouped_property(groups, group, semantic_property(name, value, index=index, source=source))
|
||||
if row.get("category"):
|
||||
add_grouped_property(groups, "Основные", semantic_property("Категория", row.get("category"), source="decoder"))
|
||||
add_grouped_property(groups, "Основные", semantic_property("Вид", row.get("category"), source="decoder"))
|
||||
@@ -3850,6 +3859,37 @@ def enrich_button_command_semantics(items: list[dict[str, Any]], links: list[dic
|
||||
)
|
||||
|
||||
|
||||
FORM_AUXILIARY_ITEM_TYPES = {
|
||||
"Контекстное меню", "Расширенная подсказка", "SearchStringAddition",
|
||||
"ViewStatusAddition", "SearchControlAddition",
|
||||
}
|
||||
|
||||
|
||||
def form_item_coverage_summary(items: list[dict[str, Any]]) -> dict[str, Any]:
|
||||
"""Report semantic coverage without auxiliary form records hiding control quality."""
|
||||
buckets = {
|
||||
"all_items": {"items": 0, "mapped": 0, "unmapped": 0},
|
||||
"interactive_items": {"items": 0, "mapped": 0, "unmapped": 0},
|
||||
"auxiliary_items": {"items": 0, "mapped": 0, "unmapped": 0},
|
||||
}
|
||||
for item in items:
|
||||
if not isinstance(item, dict):
|
||||
continue
|
||||
coverage = (item.get("semantic") or {}).get("coverage") if isinstance(item.get("semantic"), dict) else None
|
||||
if not isinstance(coverage, dict):
|
||||
continue
|
||||
target = "auxiliary_items" if str(item.get("type_name") or "") in FORM_AUXILIARY_ITEM_TYPES else "interactive_items"
|
||||
for bucket_name in ("all_items", target):
|
||||
bucket = buckets[bucket_name]
|
||||
bucket["items"] += 1
|
||||
bucket["mapped"] += int(coverage.get("mapped") or 0)
|
||||
bucket["unmapped"] += int(coverage.get("unmapped") or 0)
|
||||
for bucket in buckets.values():
|
||||
bucket["total"] = bucket["mapped"] + bucket["unmapped"]
|
||||
bucket["status"] = "partial" if bucket["unmapped"] else "ok"
|
||||
return buckets
|
||||
|
||||
|
||||
def decode_form_payload(
|
||||
tree: Any,
|
||||
*,
|
||||
@@ -3906,11 +3946,13 @@ def decode_form_payload(
|
||||
form_parameters = form_common_parameters(tree, limit=max_parameters)
|
||||
form_semantic = form_common_semantic(form_parameters, include_diagnostics=include_parameters)
|
||||
enrich_form_common_semantic(form_semantic, items)
|
||||
coverage_summary = form_item_coverage_summary(items)
|
||||
result = {
|
||||
"schema": "onec_form_payload_profile.v1",
|
||||
"status": "ok" if root.get("root_marker") == "4" else "not_form_payload",
|
||||
"root": root,
|
||||
"form_semantic": form_semantic,
|
||||
"item_coverage": coverage_summary,
|
||||
**({"form_parameters": form_parameters} if include_parameters else {}),
|
||||
"events": events,
|
||||
"items": items,
|
||||
|
||||
Reference in New Issue
Block a user