From 0fbccefeed8113e95be11c3c236f98591f9f1a1d Mon Sep 17 00:00:00 2001 From: Alf Eaton Date: Mon, 5 Feb 2024 11:41:49 +0000 Subject: [PATCH] Use prefixed strings for tracked counts of compile errors (#16870) GitOrigin-RevId: 4023822a73c204fe1365cdc0fe311b4289a8cbcf --- .../js/features/pdf-preview/util/output-files.js | 14 ++++++++------ .../js/shared/context/local-compile-context.tsx | 6 ++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/services/web/frontend/js/features/pdf-preview/util/output-files.js b/services/web/frontend/js/features/pdf-preview/util/output-files.js index 64fe101b3f..bcbb7d48a7 100644 --- a/services/web/frontend/js/features/pdf-preview/util/output-files.js +++ b/services/web/frontend/js/features/pdf-preview/util/output-files.js @@ -164,12 +164,14 @@ export function buildLogEntryAnnotations(entries, fileTreeData, rootDocId) { return logEntryAnnotations } -export const countRules = (entries = []) => - entries.reduce((counts, entry) => { - const { ruleId } = entry - counts[ruleId] = counts[ruleId] ? counts[ruleId] + 1 : 1 - return counts - }, {}) +export const buildRuleCounts = (entries = []) => { + const counts = {} + for (const entry of entries) { + const key = `${entry.level}_${entry.ruleId}` + counts[key] = counts[key] ? counts[key] + 1 : 1 + } + return counts +} function buildURL(file, pdfDownloadDomain) { if (file.build && pdfDownloadDomain) { diff --git a/services/web/frontend/js/shared/context/local-compile-context.tsx b/services/web/frontend/js/shared/context/local-compile-context.tsx index 25a94b29de..6fded1ce16 100644 --- a/services/web/frontend/js/shared/context/local-compile-context.tsx +++ b/services/web/frontend/js/shared/context/local-compile-context.tsx @@ -21,7 +21,7 @@ import { } from '../../infrastructure/event-tracking' import { buildLogEntryAnnotations, - countRules, + buildRuleCounts, handleLogFiles, handleOutputFiles, } from '../../features/pdf-preview/util/output-files' @@ -414,9 +414,7 @@ export const LocalCompileProvider: FC = ({ children }) => { stopOnFirstError: data.options.stopOnFirstError, isAutoCompileOnLoad: !!data.options.isAutoCompileOnLoad, isAutoCompileOnChange: !!data.options.isAutoCompileOnChange, - errors: countRules(result.logEntries.errors), - warnings: countRules(result.logEntries.warnings), - typesetting: countRules(result.logEntries.typesetting), + ...buildRuleCounts(result.logEntries.all), }) } }