АРЧ АП11 - Архитектура после регресса: Архитектура: сделать profile exact-ответы business-first и убрать служебный aggregate-пreamble

This commit is contained in:
2026-04-18 15:17:38 +03:00
parent d8ce2b7d88
commit 4bb0187510
4 changed files with 119 additions and 30 deletions
@@ -2861,11 +2861,30 @@ function composeFactualReplyBody(
focus === "full_profile" || focus === "sections_only" || focus === "sections_rare_only";
const includeDocTypesLowOnly = focus === "doc_types_rare_only";
const includeSectionsLowOnly = focus === "sections_rare_only";
const topDocType = docTypeRanking[0] ?? null;
const rareDocType = docTypeRankingLow[0] ?? null;
const topSection = sectionRanking[0] ?? null;
const rareSection = sectionRankingLow[0] ?? null;
const formatSectionTitle = (section: string): string => {
const label = ACCOUNT_SECTION_LABELS[section];
return label ? `${section} (${label})` : section;
};
const lines: string[] = [
"Профиль типов документов и разделов учета собран (movement-based aggregate).",
`Строк агрегата: ${rows.length}.`
];
const directLeadParts: string[] = [];
if (includeDocTypesLowOnly && rareDocType) {
directLeadParts.push(`реже всего используется тип документа ${rareDocType.docType} (${rareDocType.count})`);
} else if (includeDocTypes && topDocType) {
directLeadParts.push(`чаще всего используется тип документа ${topDocType.docType} (${topDocType.count})`);
}
if (includeSectionsLowOnly && rareSection) {
directLeadParts.push(`среди разделов учета минимальная активность у ${formatSectionTitle(rareSection.section)} (${rareSection.count})`);
} else if (includeSections && topSection) {
directLeadParts.push(`среди разделов учета лидирует ${formatSectionTitle(topSection.section)} (${topSection.count})`);
}
const lines: string[] = directLeadParts.length > 0
? [`Коротко: ${directLeadParts.join("; ")}.`]
: ["Коротко: по доступному срезу профиль типов документов и разделов учета не подтвердился."];
if (includeDocTypes) {
if (docTypeRanking.length > 0) {
@@ -2901,8 +2920,7 @@ function composeFactualReplyBody(
lines.push("Наименее заполненные разделы учета (по операциям Дт+Кт):");
lines.push(
...sectionRankingLow.map((item, index) => {
const label = ACCOUNT_SECTION_LABELS[item.section];
const sectionTitle = label ? `${item.section} (${label})` : item.section;
const sectionTitle = formatSectionTitle(item.section);
const share = formatPercent(item.count, sectionTotal);
return share
? `${index + 1}. ${sectionTitle}: ${item.count} (${share})`
@@ -2913,8 +2931,7 @@ function composeFactualReplyBody(
lines.push("Наиболее заполненные разделы учета (по операциям Дт+Кт):");
lines.push(
...sectionRanking.slice(0, 10).map((item, index) => {
const label = ACCOUNT_SECTION_LABELS[item.section];
const sectionTitle = label ? `${item.section} (${label})` : item.section;
const sectionTitle = formatSectionTitle(item.section);
const share = formatPercent(item.count, sectionTotal);
return share
? `${index + 1}. ${sectionTitle}: ${item.count} (${share})`
@@ -2925,8 +2942,7 @@ function composeFactualReplyBody(
lines.push("Разделы с минимальной активностью (среди использованных):");
lines.push(
...sectionRankingLow.map((item, index) => {
const label = ACCOUNT_SECTION_LABELS[item.section];
const sectionTitle = label ? `${item.section} (${label})` : item.section;
const sectionTitle = formatSectionTitle(item.section);
return `${index + 1}. ${sectionTitle}: ${item.count}`;
})
);
@@ -3024,10 +3040,36 @@ function composeFactualReplyBody(
operationalWindow.dataTo !== null &&
operationalWindow.operationalTo < operationalWindow.dataTo;
const lines: string[] = [
"Профиль периодов базы собран (movement-based aggregate).",
`Строк агрегата: ${rows.length}.`
];
const directLeadParts: string[] = [];
if (includeCoverage) {
if (
hasTailYears &&
operationalWindow.operationalFrom !== null &&
operationalWindow.operationalTo !== null
) {
directLeadParts.push(
`рабочий период с выраженной активностью: ${operationalWindow.operationalFrom}..${operationalWindow.operationalTo}`
);
} else if (minDate || maxDate) {
directLeadParts.push(`данные в базе подтверждены за период ${minDate ?? "н/д"} .. ${maxDate ?? "н/д"}`);
}
}
if (includeTopYear && topYearByDocs) {
directLeadParts.push(`самый активный год по документам — ${topYearByDocs.year} (${topYearByDocs.count})`);
}
if (includeBottomYear && bottomYearByDocs) {
directLeadParts.push(`самый спокойный год по документам — ${bottomYearByDocs.year} (${bottomYearByDocs.count})`);
}
if (includeTopMonth && topMonthByOps) {
directLeadParts.push(`самый активный месяц по операциям — ${topMonthByOps.month} (${topMonthByOps.count})`);
}
if (includeBottomMonth && bottomMonthByOps) {
directLeadParts.push(`самый спокойный месяц по операциям — ${bottomMonthByOps.month} (${bottomMonthByOps.count})`);
}
const lines: string[] = directLeadParts.length > 0
? [`Коротко: ${directLeadParts.join("; ")}.`]
: ["Коротко: по доступному срезу периодический профиль базы не подтвердился."];
if (includeCoverage) {
if (