diff --git a/api-server/server/boot/certificate.js b/api-server/server/boot/certificate.js index 3e0b91b39b..d5ca128c5c 100644 --- a/api-server/server/boot/certificate.js +++ b/api-server/server/boot/certificate.js @@ -21,6 +21,7 @@ import { infosecQaId, fullStackId } from '../utils/constantStrings.json'; +import { oldDataVizId } from '../../../config/misc'; import certTypes from '../utils/certTypes.json'; import superBlockCertTypeMap from '../utils/superBlockCertTypeMap'; import { completeCommitment$ } from '../utils/commit'; @@ -437,12 +438,10 @@ function createShowCert(app) { let { completedDate = new Date() } = certChallenge || {}; // the challenge 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 + ({ id }) => oldDataVizId === id ); if (oldDataVisIdChall) { @@ -450,6 +449,17 @@ function createShowCert(app) { } } + // if fullcert is not found, return the latest completedDate + if (certType === 'isFullStackCert' && !certChallenge) { + var chalIds = [...Object.values(certIds), oldDataVizId]; + + const latestCertDate = completedChallenges + .filter(chal => chalIds.includes(chal.id)) + .sort((a, b) => a.completedDate < b.completedDate)[0].completedDate; + + completedDate = latestCertDate ? latestCertDate : completedDate; + } + const { username, name } = user; return res.json({ certTitle, diff --git a/config/misc.js b/config/misc.js new file mode 100644 index 0000000000..8ecedeef31 --- /dev/null +++ b/config/misc.js @@ -0,0 +1 @@ +exports.oldDataVizId = '561add10cb82ac38a17513b3';