Skip to content

Commit 7ae1478

Browse files
committed
fix: building csv if the amount of langugage varys between participants
1 parent 84aa1ee commit 7ae1478

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

apps/backend/src/system/reports/reports.service.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ export class ReportsService {
2424
],
2525
});
2626

27+
const columnKeys = new Set(['participant'])
28+
2729
const evaluatedExposurePerParticipant = participants.map((participant) => {
2830
const exposure = this.getParticipantExposure(participant);
2931
const sortedExposureEntries = Array.from(exposure).sort(([_a, exposureA], [_b, exposureB]) => exposureB - exposureA);
@@ -34,14 +36,15 @@ export class ReportsService {
3436
acc[`L${index + 1}`] = duration / exposureSum;
3537
acc[`L${index + 1}_id`] = language.id;
3638
acc[`L${index + 1}_name`] = language.name;
39+
columnKeys.add(`L${index + 1}`).add(`L${index + 1}_id`).add(`L${index + 1}_name`)
3740

3841
return acc;
3942
},
4043
{ participant: participant.id }
4144
);
4245
});
4346

44-
return stringify(evaluatedExposurePerParticipant, { header: true });
47+
return stringify(evaluatedExposurePerParticipant, { header: true, columns: Array.from(columnKeys) });
4548
}
4649

4750
getParticipantExposure(participant: Participant) {

0 commit comments

Comments
 (0)