Skip to content

Commit

Permalink
include transverse elements in exports
Browse files Browse the repository at this point in the history
  • Loading branch information
bellangerq committed Sep 25, 2024
1 parent be29bcf commit 7c1f5df
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions confiture-rest-api/src/audits/audit-export.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ export class AuditExportService {
const data = [];

// Column headers
data.push(["Critères", ...audit.pages.map((p) => p.name)]);
data.push([
"Critères",
"Éléments transverses",
...audit.pages.map((p) => p.name)
]);

const resultsByCriteria = groupBy(
results,
Expand All @@ -50,14 +54,21 @@ export class AuditExportService {
// Tests results
criteria.forEach((c) => {
const criterionKey = c.topic + "." + c.criterium;

const transverseStatus =
CRITERIUM_STATUS[
resultsByCriteria[criterionKey].find(
(r) => r.pageId === audit.transverseElementsPageId
).status
];
const criteriumStatuses = audit.pages.map(
(p) =>
CRITERIUM_STATUS[
resultsByCriteria[criterionKey].find((r) => r.pageId === p.id)
.status
]
);
data.push([criterionKey, ...criteriumStatuses]);
data.push([criterionKey, transverseStatus, ...criteriumStatuses]);
});

// compile data to CSV buffer
Expand Down

0 comments on commit 7c1f5df

Please sign in to comment.