From 7c1f5dfbe1446de747712731054d3fe52503329b Mon Sep 17 00:00:00 2001 From: Quentin Bellanger Date: Wed, 25 Sep 2024 11:31:11 +0200 Subject: [PATCH] include transverse elements in exports --- .../src/audits/audit-export.service.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/confiture-rest-api/src/audits/audit-export.service.ts b/confiture-rest-api/src/audits/audit-export.service.ts index 3f8a21a01..d32589850 100644 --- a/confiture-rest-api/src/audits/audit-export.service.ts +++ b/confiture-rest-api/src/audits/audit-export.service.ts @@ -38,7 +38,11 @@ export class AuditExportService { const data = []; // Column headers - data.push(["Critères", ...audit.pages.map((p) => p.name)]); + data.push([ + "Critères", + "Éléments transverses", + ...audit.pages.map((p) => p.name) + ]); const resultsByCriteria = groupBy( results, @@ -50,6 +54,13 @@ export class AuditExportService { // Tests results criteria.forEach((c) => { const criterionKey = c.topic + "." + c.criterium; + + const transverseStatus = + CRITERIUM_STATUS[ + resultsByCriteria[criterionKey].find( + (r) => r.pageId === audit.transverseElementsPageId + ).status + ]; const criteriumStatuses = audit.pages.map( (p) => CRITERIUM_STATUS[ @@ -57,7 +68,7 @@ export class AuditExportService { .status ] ); - data.push([criterionKey, ...criteriumStatuses]); + data.push([criterionKey, transverseStatus, ...criteriumStatuses]); }); // compile data to CSV buffer