From 6b95d30ecd015005f6458adcd427823c2c5af03e Mon Sep 17 00:00:00 2001 From: Quentin Bellanger Date: Thu, 7 Nov 2024 15:37:45 +0100 Subject: [PATCH] create variable for only pages results --- confiture-rest-api/src/audits/audit.service.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/confiture-rest-api/src/audits/audit.service.ts b/confiture-rest-api/src/audits/audit.service.ts index 21251bf7e..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,13 +1423,14 @@ export class AuditService { const statementIsPublished = !!a.initiator; + const pagesResults = allResults.filter( + (r) => r.pageId !== a.transverseElementsPageId + ); + const auditIsComplete = - results.filter((r) => r.pageId !== a.transverseElementsPageId) - .length === + pagesResults.length === CRITERIA_BY_AUDIT_TYPE[a.auditType].length * a.pages.length && - results - .filter((r) => r.pageId !== a.transverseElementsPageId) - .every((r) => r.status !== "NOT_TESTED"); + pagesResults.every((r) => r.status !== "NOT_TESTED"); return { ...pick(