Skip to content

Commit

Permalink
fix(applications): fetch all bodies once for JC export
Browse files Browse the repository at this point in the history
  • Loading branch information
WikiRik committed Apr 10, 2024
1 parent 495a89b commit a222831
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/applications.js
Original file line number Diff line number Diff line change
Expand Up @@ -877,10 +877,12 @@ exports.exportDelegatesJc = async (req, res) => {
mails = await core.getMails(req, userIds);
}

const bodies = await core.getBodies(req);

Check warning on line 880 in lib/applications.js

View check run for this annotation

Codecov / codecov/patch

lib/applications.js#L880

Added line #L880 was not covered by tests

// Returns a CSV string
const exportString = await Promise.all(applications.map(async (application) => {
const user = mails.find((m) => application.user_id === m.id);
const body = await core.getBody(req, application.body_id);
const body = bodies.find((b) => application.body_id === b.id);

Check warning on line 885 in lib/applications.js

View check run for this annotation

Codecov / codecov/patch

lib/applications.js#L885

Added line #L885 was not covered by tests
const regex = /[^a-zA-z\-\ ]/; // eslint-disable-line
application.first_name = application.first_name.replace(regex, '?');
application.last_name = application.last_name.replace(regex, '?');
Expand Down

0 comments on commit a222831

Please sign in to comment.