Skip to content

Commit ddffb62

Browse files
committed
refactor: simplify generate-report to use precomputed report directly
Signed-off-by: Mats Johansson <extern.mats.johansson@digg.se>
1 parent a602acd commit ddffb62

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

src/routes/validate.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,15 @@ export const registerValidationRoutes = (app: Express) => {
6161
const data = req.body;
6262
const context = new RuleExecutionContext();
6363

64-
if (!data || !data.result || !Array.isArray(data.result)) {
65-
return res.status(400).json({ error: 'Invalid data format. Expected an object with a "result" array.' });
64+
if (!data || !Array.isArray(data.report)) {
65+
return res.status(400).json({ error: 'Invalid data format. Expected an object with a "report" array.' });
6666
}
6767

6868
const reportHandler = new ExcelReportProcessor();
6969
let buffer: Buffer;
7070

71-
const ruleCategories = data.categories && data.categories.length > 0 ? data.categories : undefined;
72-
73-
const enabledRulesAndCategorys = await importAndCreateRuleInstances(ruleCategories);
7471
const customDiagnostic = new RapLPDiagnostic(context);
75-
if (data.report && Array.isArray(data.report) && data.report.length > 0) {
76-
customDiagnostic.setFromPrecomputedReport(data.report);
77-
} else {
78-
customDiagnostic.processRuleExecutionInformation(data.result, enabledRulesAndCategorys.rules, enabledRulesAndCategorys.instanceCategoryMap);
79-
}
72+
customDiagnostic.setFromPrecomputedReport(data.report);
8073
const diagnosticReports: DiagnosticReport[] = customDiagnostic.processDiagnosticInformation();
8174

8275
try {

0 commit comments

Comments
 (0)