Skip to content

Commit

Permalink
fix: correct cert date for legacy data visualization (#35728)
Browse files Browse the repository at this point in the history
Closes #34890
Closes #17424
  • Loading branch information
ahmaxed authored and raisedadead committed Apr 2, 2019
1 parent e5d0597 commit b4d3e6d
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions api-server/server/boot/certificate.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,25 @@ function createShowCert(app) {

if (user[certType]) {
const { completedChallenges = [] } = user;
const { completedDate = new Date() } =
_.find(completedChallenges, ({ id }) => certId === id) || {};
const certChallenge = _.find(
completedChallenges,
({ id }) => certId === id
);
let { completedDate = new Date() } = certChallenge || {};

// the challange id has been rotated for isDataVisCert
// so we need to check for id 561add10cb82ac38a17513b3
if (certType === 'isDataVisCert' && !certChallenge) {
console.log('olderId');
let oldDataVisIdChall = _.find(
completedChallenges,
({ id }) => '561add10cb82ac38a17513b3' === id
);

if (oldDataVisIdChall) {
completedDate = oldDataVisIdChall.completedDate || completedDate;
}
}

const { username, name } = user;
return res.json({
Expand Down

0 comments on commit b4d3e6d

Please sign in to comment.