Skip to content

Commit

Permalink
fix(applications): improve perf delegates export (#1188)
Browse files Browse the repository at this point in the history
Co-authored-by: WikiRik <[email protected]>
  • Loading branch information
WikiRik and WikiRik committed Apr 5, 2024
1 parent 1af19ec commit aa5762d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/applications.js
Original file line number Diff line number Diff line change
Expand Up @@ -870,9 +870,16 @@ exports.exportDelegatesJc = async (req, res) => {

const applications = await Application.findAll({ where: { event_id: req.event.id, cancelled: false, status: 'accepted', participant_type: 'delegate' } });

let mails = [];

if (applications.length > 0) {
const userIds = applications.map((application) => application.user_id).toString();
mails = await core.getMails(req, userIds);
}

// Returns a CSV string
const exportString = await Promise.all(applications.map(async (application) => {
const user = await core.getMember(req, application.user_id);
const user = mails.find((m) => application.user_id === m.id);
const body = await core.getBody(req, application.body_id);
const regex = /[^a-zA-z\-\ ]/; // eslint-disable-line
application.first_name = application.first_name.replace(regex, '?');
Expand Down

0 comments on commit aa5762d

Please sign in to comment.