Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(applications): improve perf delegates export #1188

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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