Use prefixed strings for tracked counts of compile errors (#16870)

GitOrigin-RevId: 4023822a73c204fe1365cdc0fe311b4289a8cbcf
This commit is contained in:
Alf Eaton 2024-02-05 11:41:49 +00:00 committed by Copybot
parent fd717dff01
commit a3ba2284d6
2 changed files with 10 additions and 10 deletions

View file

@ -164,12 +164,14 @@ export function buildLogEntryAnnotations(entries, fileTreeData, rootDocId) {
return logEntryAnnotations return logEntryAnnotations
} }
export const countRules = (entries = []) => export const buildRuleCounts = (entries = []) => {
entries.reduce((counts, entry) => { const counts = {}
const { ruleId } = entry for (const entry of entries) {
counts[ruleId] = counts[ruleId] ? counts[ruleId] + 1 : 1 const key = `${entry.level}_${entry.ruleId}`
return counts counts[key] = counts[key] ? counts[key] + 1 : 1
}, {}) }
return counts
}
function buildURL(file, pdfDownloadDomain) { function buildURL(file, pdfDownloadDomain) {
if (file.build && pdfDownloadDomain) { if (file.build && pdfDownloadDomain) {

View file

@ -21,7 +21,7 @@ import {
} from '../../infrastructure/event-tracking' } from '../../infrastructure/event-tracking'
import { import {
buildLogEntryAnnotations, buildLogEntryAnnotations,
countRules, buildRuleCounts,
handleLogFiles, handleLogFiles,
handleOutputFiles, handleOutputFiles,
} from '../../features/pdf-preview/util/output-files' } from '../../features/pdf-preview/util/output-files'
@ -414,9 +414,7 @@ export const LocalCompileProvider: FC = ({ children }) => {
stopOnFirstError: data.options.stopOnFirstError, stopOnFirstError: data.options.stopOnFirstError,
isAutoCompileOnLoad: !!data.options.isAutoCompileOnLoad, isAutoCompileOnLoad: !!data.options.isAutoCompileOnLoad,
isAutoCompileOnChange: !!data.options.isAutoCompileOnChange, isAutoCompileOnChange: !!data.options.isAutoCompileOnChange,
errors: countRules(result.logEntries.errors), ...buildRuleCounts(result.logEntries.all),
warnings: countRules(result.logEntries.warnings),
typesetting: countRules(result.logEntries.typesetting),
}) })
} }
} }