Skip to content

Commit 6fd12de

Browse files
authored
Merge pull request #343 from openscript-ch/320-report-function-only-provides-data-for-l1
320 report function only provides data for l1
2 parents 84aa1ee + 25926a4 commit 6fd12de

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

.changeset/five-rings-joke.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@quassel/backend": patch
3+
---
4+
5+
Fix report csv if the amount of langugage varys between participants

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

Lines changed: 7 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,18 @@ 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
40+
.add(`L${index + 1}`)
41+
.add(`L${index + 1}_id`)
42+
.add(`L${index + 1}_name`);
3743

3844
return acc;
3945
},
4046
{ participant: participant.id }
4147
);
4248
});
4349

44-
return stringify(evaluatedExposurePerParticipant, { header: true });
50+
return stringify(evaluatedExposurePerParticipant, { header: true, columns: Array.from(columnKeys) });
4551
}
4652

4753
getParticipantExposure(participant: Participant) {

0 commit comments

Comments
 (0)