Skip to content

Commit

Permalink
Vérifie le nombre de critères non-transverses uniquement pour le stat…
Browse files Browse the repository at this point in the history
…ut de l'audit dans la liste des audits (#871)

* only check length for pages criteria

* create variable for only pages results
  • Loading branch information
bellangerq authored Nov 7, 2024
1 parent d18e4a7 commit 9c29955
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions confiture-rest-api/src/audits/audit.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, CriterionResult[]>
>((acc, c) => {
const key = `${c.topic}.${c.criterium}`;
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 9c29955

Please sign in to comment.