Add HTML5 object knowledge context
CI / python (push) Has been cancelled
CI / rust (push) Has been cancelled

This commit is contained in:
2026-05-17 00:14:55 +03:00
parent b93fd88e81
commit f695846b7b
3 changed files with 66 additions and 1 deletions
+36 -1
View File
@@ -1748,8 +1748,9 @@ async def html5_project_object_context(project_id: str, object_name: str) -> Res
access = await get_object_access(project_id, object_name)
ui = await get_object_ui(project_id, object_name)
runtime = _runtime_for_object_context(project_id, impact)
knowledge = _knowledge_for_object_context(schema, impact, ui)
return Response(
render_html5_object_context(project_id, schema, impact, access, ui, runtime),
render_html5_object_context(project_id, schema, impact, access, ui, runtime, knowledge),
media_type="text/html; charset=utf-8",
)
@@ -8142,6 +8143,40 @@ def _runtime_for_object_context(project_id: str, impact: ObjectImpactResponse) -
]
def _knowledge_for_object_context(
schema: ObjectSchemaResponse,
impact: ObjectImpactResponse,
ui: ObjectUiResponse,
) -> list[KnowledgeRecord]:
lineages: set[str] = {schema.object.lineage_id, impact.object.lineage_id}
lineages.update(item.lineage_id for item in schema.attributes)
for section in schema.tabular_sections:
lineages.add(section.tabular_section.lineage_id)
lineages.update(column.lineage_id for column in section.columns)
for group in [
impact.modules,
impact.routines,
impact.forms,
impact.commands,
impact.roles,
impact.jobs,
impact.writes,
impact.query_tables,
]:
lineages.update(item.lineage_id for item in group)
for form in ui.forms:
lineages.add(form.form.lineage_id)
lineages.update(command.lineage_id for command in form.commands)
lineages.update(element.lineage_id for element in form.elements)
lineages.update(handler.lineage_id for handler in form.command_handlers.values())
records = [
record
for record in _knowledge.list_records()
if lineages.intersection(record.related_lineages)
]
return sorted(records, key=lambda item: item.title.lower())[:12]
def _current_import_source(project_id: str) -> ImportSourceKind:
setup = _project_setup_response(project_id)
if setup.current_source is not None: