Skip to content

Commit

Permalink
chore: conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
20chen-7 committed Sep 2, 2024
1 parent f7d7c07 commit 6c33cd1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/controllers/userProfileController.js
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ const userProfileController = function (UserProfile, Project) {
}
});

// Since we leverage cache for all team code retrival (refer func getAllTeamCode()),
// Since we leverage cache for all team code retrival (refer func getAllTeamCode()),
// we need to remove the cache when team code is updated in case of new team code generation
if (req.body.teamCode) {
// remove teamCode cache when new team assigned
Expand Down Expand Up @@ -729,14 +729,14 @@ const userProfileController = function (UserProfile, Project) {
})
.catch((error) => {
if (error.name === 'ValidationError' && error.errors.lastName) {
const errors = Object.values(error.errors).map(er => er.message);
const errors = Object.values(error.errors).map((er) => er.message);
return res.status(400).json({
message: 'Validation Error',
error: errors,
});
}
console.error('Failed to save record:', error);
return res.status(400).json({ error: 'Failed to save record.' });
console.error('Failed to save record:', error);
return res.status(400).json({ error: 'Failed to save record.' });
});
});
};
Expand Down Expand Up @@ -1241,6 +1241,7 @@ const userProfileController = function (UserProfile, Project) {
endDate,
user.email,
recipients,
isSet,
);
auditIfProtectedAccountUpdated(
req.body.requestor.requestorId,
Expand Down Expand Up @@ -1606,23 +1607,25 @@ const userProfileController = function (UserProfile, Project) {
return teamCodes;
}
const distinctTeamCodes = await UserProfile.distinct('teamCode', {
teamCode: { $ne: null }
teamCode: { $ne: null },
});
cache.setCache('teamCodes', JSON.stringify(distinctTeamCodes));
return distinctTeamCodes;
} catch (error) {
throw new Error('Encountered an error to get all team codes, please try again!');
}
}
};

const getAllTeamCode = async function (req, res) {
try {
const distinctTeamCodes = await getAllTeamCodeHelper();
return res.status(200).send({ message: 'Found', distinctTeamCodes });
} catch (error) {
return res.status(500).send({ message: 'Encountered an error to get all team codes, please try again!' });
return res
.status(500)
.send({ message: 'Encountered an error to get all team codes, please try again!' });
}
}
};

return {
postUserProfile,
Expand Down
1 change: 1 addition & 0 deletions src/helpers/userHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -2114,6 +2114,7 @@ const userHelper = function () {
lastDay,
person.email,
recipients,
person.isSet,
);
}
}
Expand Down

0 comments on commit 6c33cd1

Please sign in to comment.