Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@ paths:
schema:
type: object
required:
- result
- report
properties:
result:
report:
type: array
items:
$ref: '#/components/schemas/RapLPCustomSpectralDiagnosticItem'
description: An array of result items used to generate the Excel report.
$ref: '#/components/schemas/DiagnosticReport'
description: An array of precomputed report items used to generate the Excel report.
responses:
'200':
description: Successful operation
Expand Down Expand Up @@ -489,12 +489,12 @@ components:
id:
type: string
example: "UFN.05"
omrade:
område:
type: string
example: "URL Format och namngivning"
required:
- id
- omrade
- område

PopulatedDiagnosticRuleInfo:
allOf:
Expand Down
9 changes: 3 additions & 6 deletions src/routes/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,15 @@ export const registerValidationRoutes = (app: Express) => {
const data = req.body;
const context = new RuleExecutionContext();

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

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

const ruleCategories = data.categories && data.categories.length > 0 ? data.categories : undefined;

const enabledRulesAndCategorys = await importAndCreateRuleInstances(ruleCategories);
const customDiagnostic = new RapLPDiagnostic(context);
customDiagnostic.processRuleExecutionInformation(data.result, enabledRulesAndCategorys.rules,enabledRulesAndCategorys.instanceCategoryMap);
customDiagnostic.setFromPrecomputedReport(data.report);
const diagnosticReports: DiagnosticReport[] = customDiagnostic.processDiagnosticInformation();

try {
Expand Down
15 changes: 15 additions & 0 deletions src/util/RapLPDiagnostic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,21 @@ class RapLPDiagnostic {
}
}
}
setFromPrecomputedReport(reports: { Notering: string; regler: { id: string; område: string; krav?: string; helpUrl?: string; status: string }[] }[]): void {
for (const report of reports) {
for (const regel of report.regler) {
const ruleInfo = { id: regel.id, område: regel.område, krav: regel.krav ?? '', helpUrl: regel.helpUrl };
if (regel.status === 'OK') {
this._ruleSets.executedUniqueRules.push(ruleInfo);
} else if (regel.status === 'EJ OK') {
this._ruleSets.executedUniqueRulesWithError.push(ruleInfo);
} else {
this._ruleSets.notApplicableRules.push(ruleInfo);
}
}
}
}

processDiagnosticInformation(): DiagnosticReport[] {
const allReports: DiagnosticReport[] = [];
// Populate the diagnostic reports and add them to the array
Expand Down