Skip to content

Commit

Permalink
update error log on send file route
Browse files Browse the repository at this point in the history
  • Loading branch information
birdpump committed Jul 17, 2024
1 parent 08177ba commit 5371132
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions utils/admin/csvgen/generateCSV.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,31 @@ export async function generateLockerCSV() {
//todo im not sure how useful is is to export userData, better to export Users in the format of UserData, to be able to import as as student locator
//generate a csv from database matching import format for the student locator
export async function generateUserCSV() {
try {
User.findAll().then(async users => {
const filteredData = users.map(user => ({
studentId: user.studentId,
name: user.name,
grade: user.grade,
email: user.email,
permissions: user.permissions
}));

User.findAll().then(async users => {
const filteredData = users.map(user => ({
studentId: user.studentId,
name: user.name,
grade: user.grade,
email: user.email,
permissions: user.permissions
}));
const csvWriter = createObjectCsvWriter({
path: './data-temp/user.csv',
header: [
{id: 'studentId', title: 'studentId'},
{id: 'name', title: 'name'},
{id: 'grade', title: 'grade'},
{id: 'email', title: 'email'},
{id: 'permissions', title: 'permissions'},
],
});

const csvWriter = createObjectCsvWriter({
path: './data-temp/user.csv',
header: [
{id: 'studentId', title: 'studentId'},
{id: 'name', title: 'name'},
{id: 'grade', title: 'grade'},
{id: 'email', title: 'email'},
{id: 'permissions', title: 'permissions'},
],
await csvWriter.writeRecords(filteredData);
});
} catch (error) {
console.log(error);
}

await csvWriter.writeRecords(filteredData);
});
}

0 comments on commit 5371132

Please sign in to comment.