169 build - mapping и карьерная статистика
This commit is contained in:
@@ -181,6 +181,18 @@ def _mapping_rule_matches(left: Any, operator: Any, right: Any = None) -> bool:
|
||||
return a == b
|
||||
|
||||
|
||||
def _mapping_dependency_keys(data_key: Any, rule: dict[str, Any]) -> set[str]:
|
||||
keys = {str(data_key or "").strip()}
|
||||
if rule.get("enabled"):
|
||||
keys.add(str(rule.get("left_key") or data_key or "").strip())
|
||||
if str(rule.get("right_mode") or "field").lower() != "value":
|
||||
keys.add(str(rule.get("right_key") or "").strip())
|
||||
for branch in ("true", "false"):
|
||||
if str(rule.get(f"{branch}_mode") or "value").lower() == "field":
|
||||
keys.add(str(rule.get(f"{branch}_key") or "").strip())
|
||||
return keys - {""}
|
||||
|
||||
|
||||
def _mapping_rule_command(
|
||||
rule: dict[str, Any],
|
||||
*,
|
||||
@@ -855,9 +867,10 @@ class VmixAgentHub:
|
||||
profile = self._active_mapping_profile_for_device(session, device)
|
||||
if profile is None:
|
||||
continue
|
||||
keys = session.scalars(select(VmixMappingField.data_key).where(
|
||||
fields = session.scalars(select(VmixMappingField).where(
|
||||
VmixMappingField.profile_id == profile.id, VmixMappingField.enabled.is_(True)))
|
||||
used = {self._mapping_source_code(key) for key in keys}.intersection(source_intervals)
|
||||
used = {self._mapping_source_code(key) for field in fields
|
||||
for key in _mapping_dependency_keys(field.data_key, _mapping_rule_payload(field.rule_json))}.intersection(source_intervals)
|
||||
if used:
|
||||
plan.append((str(device.device_uuid), {code: source_intervals[code] for code in used}))
|
||||
return plan
|
||||
@@ -1601,7 +1614,9 @@ class VmixAgentHub:
|
||||
)
|
||||
if source_codes is not None:
|
||||
wanted_sources = {str(code) for code in source_codes}
|
||||
fields = [field for field in fields if self._mapping_source_code(field.data_key) in wanted_sources]
|
||||
fields = [field for field in fields if any(
|
||||
self._mapping_source_code(key) in wanted_sources
|
||||
for key in _mapping_dependency_keys(field.data_key, _mapping_rule_payload(field.rule_json)))]
|
||||
profile_id = profile.id
|
||||
profile_name = profile.name
|
||||
profile_version = profile.version
|
||||
@@ -1630,13 +1645,8 @@ class VmixAgentHub:
|
||||
catalog_source_codes.add(dependency_code)
|
||||
if catalog_source_codes is not None:
|
||||
for field in fields:
|
||||
rule = _mapping_rule_payload(getattr(field, "rule_json", "{}"))
|
||||
if not bool(rule.get("enabled")):
|
||||
continue
|
||||
for dependency in (rule.get("left_key"), rule.get("right_key") if str(rule.get("right_mode") or "field").lower() != "value" else ""):
|
||||
code = self._mapping_source_code(dependency)
|
||||
if code:
|
||||
catalog_source_codes.add(code)
|
||||
catalog_source_codes.update(self._mapping_source_code(key) for key in
|
||||
_mapping_dependency_keys(field.data_key, _mapping_rule_payload(field.rule_json)))
|
||||
catalog = (
|
||||
self.mapping_data.data_catalog(user, supplied_context, source_codes=catalog_source_codes)
|
||||
if catalog_source_codes is not None
|
||||
@@ -1755,7 +1765,11 @@ class VmixAgentHub:
|
||||
result["rules_total"] += 1
|
||||
rule_function = str(rule_command.get("Function") or "")
|
||||
rule_value = str(rule_command.get("Value") or rule_function)
|
||||
rule_cache_key = (device_id, assignment_id, int(profile_id), input_ref, selected_name, rule_function, f"rule:{data_key}")
|
||||
# On and Off share one current-state slot. Separate cache keys
|
||||
# suppress the second Off after an Off -> On -> Off transition.
|
||||
rule_channel = {"SetTextVisibleOn": "text_visibility", "SetTextVisibleOff": "text_visibility",
|
||||
"SetImageVisibleOn": "image_visibility", "SetImageVisibleOff": "image_visibility"}.get(rule_function, rule_function)
|
||||
rule_cache_key = (device_id, assignment_id, int(profile_id), input_ref, selected_name, rule_channel, f"rule:{data_key}")
|
||||
if only_changed and self._mapping_value_cache.get(rule_cache_key) == rule_value:
|
||||
result["rules_unchanged"] += 1
|
||||
else:
|
||||
|
||||
@@ -405,7 +405,6 @@
|
||||
<button type="button" data-directory-section="mapping_grid" class="${state.section === "mapping_grid" ? "is-active" : ""}">Табличный Mapping</button>
|
||||
<button type="button" data-directory-section="mapping_context" class="${state.section === "mapping_context" ? "is-active" : ""}">Переменные</button>
|
||||
<button type="button" data-directory-section="mapping_sql" class="${state.section === "mapping_sql" ? "is-active" : ""}">SQL источники</button>
|
||||
${isKhlTournamentSelected() ? `<button type="button" data-directory-section="khl_site" class="${state.section === "khl_site" ? "is-active" : ""}">КХЛ сайт</button>` : ""}
|
||||
</div>
|
||||
</nav>
|
||||
<div class="hockey-directory-content">${content}</div>
|
||||
|
||||
Reference in New Issue
Block a user