Skip to content

Commit

Permalink
create variable for only pages results
Browse files Browse the repository at this point in the history
  • Loading branch information
bellangerq committed Nov 7, 2024
1 parent 5367a14 commit 6b95d30
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 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,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(
Expand Down

0 comments on commit 6b95d30

Please sign in to comment.