Skip to content

Commit

Permalink
fix audits status in account dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
bellangerq committed Oct 24, 2024
1 parent 12fe8d0 commit b20eede
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 8 additions & 0 deletions DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,11 @@ Exemple avec 89 critères applicables et 27 critères conformes :
```
Taux de conformité = (27 / 89) * 100 = 30,34%
```

## Statut d’un audit

Un audit est considéré...

- **En cours** si tous les critères ne sont pas testés (hors éléments transverses).
- **Terminé** si tous les critères sont testés (hors éléments transverses) et qu’il a une date de publication.
- **Modifié** si tous les critères sont testés (hors éléments transverses), qu’il a une date de publication et une date d’édition.
9 changes: 8 additions & 1 deletion confiture-rest-api/src/audits/audit.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1419,6 +1419,13 @@ export class AuditService {

const statementIsPublished = !!a.initiator;

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");

return {
...pick(
a,
Expand All @@ -1429,7 +1436,7 @@ export class AuditService {
"auditType"
),
complianceLevel,
status: progress < 1 ? "IN_PROGRESS" : "COMPLETED",
status: auditIsComplete ? "COMPLETED" : "IN_PROGRESS",
estimatedCsvSize: 502 + a.pages.length * 318,
statementIsPublished
};
Expand Down

0 comments on commit b20eede

Please sign in to comment.