From 52fafa96c5e506d8e768e7f0e712fa71b7a9802b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Alby?= Date: Tue, 28 Jul 2020 11:37:24 +0200 Subject: [PATCH] Merge pull request #3060 from overleaf/cmg-wfh-export-updates WFH Export: Account for user being undefined GitOrigin-RevId: 8e653fda6eaea3cdde8e5677f24ef39c1c97bb94 --- services/web/scripts/wfh_2020/wfh_2020_export.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/services/web/scripts/wfh_2020/wfh_2020_export.js b/services/web/scripts/wfh_2020/wfh_2020_export.js index 183b148d9a..b6a3a363b7 100644 --- a/services/web/scripts/wfh_2020/wfh_2020_export.js +++ b/services/web/scripts/wfh_2020/wfh_2020_export.js @@ -28,12 +28,16 @@ db.deletedSubscriptions.aggregate( 10, function(userId, callback) { db.users.findOne(userId, function(err, user) { - const emails = user.emails.map(email => email.email) - console.log( - `${user._id},${user.first_name || ''},${user.last_name || ''},${ - user.signUpDate - },${emails.join(',')}` - ) + if (user) { + const emails = user.emails.map(email => email.email) + console.log( + `${user._id},${user.first_name || ''},${user.last_name || ''},${ + user.signUpDate + },${emails.join(',')}` + ) + } else { + console.error('A group user was not found') + } callback(err) }) },