From 4bdee0e39c1c2c71a38d821bef9ee50a6b27b195 Mon Sep 17 00:00:00 2001 From: Quentin Bellanger Date: Wed, 27 Nov 2024 11:30:42 +0100 Subject: [PATCH] sort audit pages in page distributions in report --- .../src/audits/audit.service.ts | 82 +++++++++---------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/confiture-rest-api/src/audits/audit.service.ts b/confiture-rest-api/src/audits/audit.service.ts index 99c77820..f1f59672 100644 --- a/confiture-rest-api/src/audits/audit.service.ts +++ b/confiture-rest-api/src/audits/audit.service.ts @@ -879,56 +879,56 @@ export class AuditService { technologies: audit.technologies }, - pageDistributions: [audit.transverseElementsPage, ...audit.pages].map( - (p) => ({ - name: p.name, - compliant: { - raw: results.filter( + pageDistributions: [ + audit.transverseElementsPage, + ...sortBy(audit.pages, "order") + ].map((p) => ({ + name: p.name, + compliant: { + raw: results.filter( + (r) => + r.pageId === p.id && r.status === CriterionResultStatus.COMPLIANT + ).length, + percentage: + (results.filter( (r) => r.pageId === p.id && r.status === CriterionResultStatus.COMPLIANT - ).length, - percentage: - (results.filter( - (r) => - r.pageId === p.id && - r.status === CriterionResultStatus.COMPLIANT - ).length / - totalCriteriaCount) * - 100 - }, - notApplicable: { - raw: results.filter( + ).length / + totalCriteriaCount) * + 100 + }, + notApplicable: { + raw: results.filter( + (r) => + r.pageId === p.id && + r.status === CriterionResultStatus.NOT_APPLICABLE + ).length, + percentage: + (results.filter( (r) => r.pageId === p.id && r.status === CriterionResultStatus.NOT_APPLICABLE - ).length, - percentage: - (results.filter( - (r) => - r.pageId === p.id && - r.status === CriterionResultStatus.NOT_APPLICABLE - ).length / - totalCriteriaCount) * - 100 - }, - notCompliant: { - raw: results.filter( + ).length / + totalCriteriaCount) * + 100 + }, + notCompliant: { + raw: results.filter( + (r) => + r.pageId === p.id && + r.status === CriterionResultStatus.NOT_COMPLIANT + ).length, + percentage: + (results.filter( (r) => r.pageId === p.id && r.status === CriterionResultStatus.NOT_COMPLIANT - ).length, - percentage: - (results.filter( - (r) => - r.pageId === p.id && - r.status === CriterionResultStatus.NOT_COMPLIANT - ).length / - totalCriteriaCount) * - 100 - } - }) - ), + ).length / + totalCriteriaCount) * + 100 + } + })), resultDistribution: { compliant: {