From 9c29955f2e77700d2ab7ffe776b56320a8c68c20 Mon Sep 17 00:00:00 2001 From: Quentin Bellanger Date: Thu, 7 Nov 2024 15:46:10 +0100 Subject: [PATCH] =?UTF-8?q?V=C3=A9rifie=20le=20nombre=20de=20crit=C3=A8res?= =?UTF-8?q?=20non-transverses=20uniquement=20pour=20le=20statut=20de=20l'a?= =?UTF-8?q?udit=20dans=20la=20liste=20des=20audits=20(#871)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * only check length for pages criteria * create variable for only pages results --- confiture-rest-api/src/audits/audit.service.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/confiture-rest-api/src/audits/audit.service.ts b/confiture-rest-api/src/audits/audit.service.ts index 27fc4c4bb..e1ab4d598 100644 --- a/confiture-rest-api/src/audits/audit.service.ts +++ b/confiture-rest-api/src/audits/audit.service.ts @@ -1368,20 +1368,20 @@ export class AuditService { }); const unorderedAudits = audits.map((a) => { - const results = [ + const allResults = [ ...a.transverseElementsPage.results, ...a.pages.flatMap((p) => p.results) ]; const progress = - results.filter((r) => r.status !== CriterionResultStatus.NOT_TESTED) + allResults.filter((r) => r.status !== CriterionResultStatus.NOT_TESTED) .length / (CRITERIA_BY_AUDIT_TYPE[a.auditType].length * a.pages.length); let complianceLevel = null; if (progress >= 1) { - const resultsGroupedById = results.reduce< + const resultsGroupedById = allResults.reduce< Record >((acc, c) => { const key = `${c.topic}.${c.criterium}`; @@ -1423,12 +1423,14 @@ export class AuditService { const statementIsPublished = !!a.initiator; + const pagesResults = allResults.filter( + (r) => r.pageId !== a.transverseElementsPageId + ); + const auditIsComplete = - results.length === - CRITERIA_BY_AUDIT_TYPE[a.auditType].length * (a.pages.length + 1) && - results - .filter((r) => r.pageId !== a.transverseElementsPageId) - .every((r) => r.status !== "NOT_TESTED"); + pagesResults.length === + CRITERIA_BY_AUDIT_TYPE[a.auditType].length * a.pages.length && + pagesResults.every((r) => r.status !== "NOT_TESTED"); return { ...pick(