From cf1ba11bf7a512fa07750b4bd2449e75ebdf7096 Mon Sep 17 00:00:00 2001 From: Yuri Yaryshev Date: Wed, 14 Oct 2026 20:11:31 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=B8=D0=B7=D1=83=D0=B0=D0=BB=D0=B8?= =?UTF-8?q?=D0=B7=D0=B0=D1=82=D0=BE=D1=80:=20=C2=AB=D1=80=D0=BE=D0=BB?= =?UTF-8?q?=D1=8C=20-=20=D0=98=D0=BC=D1=8F=C2=BB=20=D0=B2=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=B4=D1=81=D0=BA=D0=B0=D0=B7=D0=BA=D0=B0=D1=85=20=D1=81=D0=BE?= =?UTF-8?q?=D0=B1=D0=B8=D1=80=D0=B0=D0=B5=D1=82=D1=81=D1=8F=20=D0=B8=D0=B7?= =?UTF-8?q?=20=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BE=D1=87=D0=BD=D0=B8=D0=BA?= =?UTF-8?q?=D0=B0,=20=D0=BA=D0=BB=D1=8E=D1=87=20=D1=81=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BE=D1=87=D0=BD=D0=B8=D0=BA=D0=B0=20-=20=D0=BE=D0=B1?= =?UTF-8?q?=D1=8B=D1=87=D0=BD=D1=8B=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 5.5 --- packages/khbuild_process_viz/src/model.ts | 16 +++++++++---- packages/khbuild_process_viz/src/viz.test.ts | 24 ++++++++++---------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/packages/khbuild_process_viz/src/model.ts b/packages/khbuild_process_viz/src/model.ts index 1d7447d..074635b 100644 --- a/packages/khbuild_process_viz/src/model.ts +++ b/packages/khbuild_process_viz/src/model.ts @@ -9,7 +9,7 @@ export interface ProcessRow { stage: string | null; actionName: string | null; description: string | null; - /** ключи справочника ответственных (колонки responsible, responsible2, responsible3), вида «роль - Имя» */ + /** ключи справочника ответственных (колонки responsible, responsible2, responsible3) */ responsible: string[]; /** роль первого ответственного (для дорожек ARIS); для архива khnata - колонка responsible_role */ role: string | null; @@ -27,7 +27,7 @@ export interface ProcessRow { /** признак вехи: колонка is_milestone; если колонки нет или она пустая - вехами считаются чек-поинты CP-* */ isMilestone: boolean; } -/** Запись справочника ответственных: ключ `id` = «роль - Имя». */ +/** Запись справочника ответственных: `id` - обычный ключ, роль и имя хранятся отдельно (склейку «роль - Имя» делает Mathesar и визуализатор). */ export interface ResponsibleRow { id: string; role: string | null; person: string | null; comment: string | null } /** Роль (производная от справочника ответственных): имена всех ответственных этой роли. */ export interface RoleRow { id: string; person: string | null; comment: string | null } @@ -121,9 +121,17 @@ export function buildModel(set: ProcessSet, raw: RawStar): ProcessModel { }; } -/** Ответственные строки для подсказок: ключи «роль - Имя»; для архива (колонки роль и имя) - в прежнем виде. */ +/** Ответственные для подсказок: «роль - Имя» по справочнику; для архива (колонки роль и имя) - в прежнем виде. */ export function describeResponsible(row: ProcessRow, model: ProcessModel): string { - if (row.responsible.length) return row.responsible.join("; "); + if (row.responsible.length) { + const byId = new Map(model.responsible.map((r) => [r.id, r])); + return row.responsible + .map((id) => { + const r = byId.get(id); + return r ? [r.role, r.person].filter(Boolean).join(" - ") : id; + }) + .join("; "); + } const roleLabel = row.role ? model.roles.find((r) => r.id === row.role)?.person ?? row.role : null; return [roleLabel, row.responsibleName].filter(Boolean).join(" / ") || "не указан"; } diff --git a/packages/khbuild_process_viz/src/viz.test.ts b/packages/khbuild_process_viz/src/viz.test.ts index 8d197e4..afd203c 100644 --- a/packages/khbuild_process_viz/src/viz.test.ts +++ b/packages/khbuild_process_viz/src/viz.test.ts @@ -72,25 +72,25 @@ describe("каноническая длительность", () => { describe("справочник ответственных", () => { const raw = { process: [ - { id: "CP-0", responsible: "architect - RIOS", responsible2: "arch_permit_lead - Андрей", data_out1: "Plan" }, - { id: "S-1", responsible: "pm - PM" }, + { id: "CP-0", responsible: "architect", responsible2: "arch_permit_lead", data_out1: "Plan" }, + { id: "S-1", responsible: "pm" }, { id: "S-2" }, ], refs: [ - { id: "architect - RIOS", role: "architect", person: "RIOS", comment: null }, - { id: "arch_permit_lead - Андрей", role: "arch_permit_lead", person: "Андрей", comment: "уточнить" }, - { id: "specs_client_mgr - Austin", role: "specs_client_mgr", person: "Austin", comment: null }, - { id: "specs_client_mgr - Маша", role: "specs_client_mgr", person: "Маша", comment: "делит с Austin" }, - { id: "pm - PM", role: "pm", person: "PM", comment: null }, + { id: "architect", role: "architect", person: "RIOS", comment: null }, + { id: "arch_permit_lead", role: "arch_permit_lead", person: "Андрей", comment: "уточнить" }, + { id: "specs_client_mgr", role: "specs_client_mgr", person: "Austin", comment: null }, + { id: "specs_client_mgr_2", role: "specs_client_mgr", person: "Маша", comment: "делит с Austin" }, + { id: "pm", role: "pm", person: "PM", comment: null }, ], legacyRoles: false, systems: [], - data: [{ id: "Plan", data_description: "План", responsible: "architect - RIOS", comment: null }], + data: [{ id: "Plan", data_description: "План", responsible: "architect", comment: null }], }; it("колонки responsible, responsible2, responsible3 дают список ключей, роль берётся у первого", () => { const m = buildModel("khbuild", raw); - expect(m.rows[0]).toMatchObject({ responsible: ["architect - RIOS", "arch_permit_lead - Андрей"], role: "architect", responsibleName: "RIOS; Андрей" }); - expect(m.rows[1]).toMatchObject({ responsible: ["pm - PM"], role: "pm" }); + expect(m.rows[0]).toMatchObject({ responsible: ["architect", "arch_permit_lead"], role: "architect", responsibleName: "RIOS; Андрей" }); + expect(m.rows[1]).toMatchObject({ responsible: ["pm"], role: "pm" }); expect(m.rows[2]).toMatchObject({ responsible: [], role: null }); expect(describeResponsible(m.rows[0]!, m)).toBe("architect - RIOS; arch_permit_lead - Андрей"); expect(describeResponsible(m.rows[2]!, m)).toBe("не указан"); @@ -176,8 +176,8 @@ describe("computeSchedule", () => { const model: ProcessModel = { set: "khbuild", responsible: [ - { id: "architect - RIOS", role: "architect", person: "RIOS", comment: null }, - { id: "pm - PM", role: "pm", person: "PM", comment: "кто именно?" }, + { id: "architect", role: "architect", person: "RIOS", comment: null }, + { id: "pm", role: "pm", person: "PM", comment: "кто именно?" }, ], roles: [ { id: "architect", person: "RIOS", comment: null },