Skip to content

Commit 5f8b5d8

Browse files
Merge pull request #3637 from gitcoinco/PAR-382
fix: ensure all columns are present in csv
2 parents 478ec0c + 5e9a4e9 commit 5f8b5d8

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/round-manager/src/features/api/exports.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,16 @@ export async function roundApplicationsToCSV(
5555
});
5656

5757
const decryptedData: Record<string, string>[] = [];
58+
const columns = new Set();
59+
5860

5961
for (const application of applications) {
6062
const answers =
6163
// eslint-disable-next-line @typescript-eslint/no-explicit-any
6264
application.metadata?.application.answers.flatMap((answer: any) => {
65+
66+
columns.add(answer.question);
67+
6368
if (answer.answer) {
6469
return [[answer.question, answer.answer]];
6570
} else if (answer.encryptedAnswer) {
@@ -109,15 +114,16 @@ export async function roundApplicationsToCSV(
109114
});
110115
}
111116

117+
const columnsArray = Array.from(columns) as string[];
118+
112119
const csv = (await new Promise((resolve, reject) => {
113-
stringifyCsv(decryptedData, { header: true }, (err, data) => {
120+
stringifyCsv(decryptedData, { header: true , columns: columnsArray}, (err, data) => {
114121
if (err) {
115122
reject(err);
116123
} else {
117124
resolve(data);
118125
}
119126
});
120127
})) as string;
121-
122128
return csv;
123129
}

0 commit comments

Comments
 (0)