Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function isNotReceived (date, minutesToAdd, now) {
if (!date || !moment.isMoment(date)) {
// can be undefined
return false
}
if (!now || !moment.isMoment(now)) {
return false
}
if (!isPositive(minutesToAdd)) {
throw new Error('minutesToAdd is not a positive number')
}
const expiry = date.add(minutesToAdd, 'minutes')
return expiry.isBefore(now)
}
pupilCheckComplete,
pupilId,
pupilLoginDate,
restartAvailable
} = arg
if (pinExpiresAt && !moment.isMoment(pinExpiresAt)) {
throw new Error('pinExpiresAt must be null or a Moment.moment datetime')
}
if (isPositive(attendanceId)) {
status = 'Not taking the Check'
} else if (isTrue(restartAvailable)) {
status = 'Restart'
} else if ((isNil(currentCheckId) && isNil(checkStatusCode)) ||
(isPositive(currentCheckId) && isNew(checkStatusCode) &&
(isNil(pinExpiresAt) || isExpired(pinExpiresAt)))) {
status = 'Not started'
} else if (isPositive(currentCheckId) && isNew(checkStatusCode)) {
status = 'PIN generated'
} else if (isPositive(currentCheckId) && isCollected(checkStatusCode) && isFalse(checkReceived)) {
status = 'Logged in'
if (isNotReceived(pupilLoginDate, notReceivedExpiryInMinutes, moment.utc())) {
status = 'Incomplete'
}
} else if (isTrue(checkReceived) && isTrue(checkComplete) && isComplete(checkStatusCode) && isTrue(pupilCheckComplete)) {
status = 'Complete'
} else {
logger.error(`getProcessStatusV2(): ERROR: Unable to determine status for pupil [${pupilId}] arg was: \n` +
JSON.stringify(arg, ' ', 4))
}
if (pinExpiresAt && !moment.isMoment(pinExpiresAt)) {
throw new Error('pinExpiresAt must be null or a Moment.moment datetime')
}
if (isPositive(attendanceId)) {
status = 'Not taking the Check'
} else if (isTrue(restartAvailable)) {
status = 'Restart'
} else if ((isNil(currentCheckId) && isNil(checkStatusCode)) ||
(isPositive(currentCheckId) && isNew(checkStatusCode) &&
(isNil(pinExpiresAt) || isExpired(pinExpiresAt)))) {
status = 'Not started'
} else if (isPositive(currentCheckId) && isNew(checkStatusCode)) {
status = 'PIN generated'
} else if (isPositive(currentCheckId) && isCollected(checkStatusCode) && isFalse(checkReceived)) {
status = 'Logged in'
if (isNotReceived(pupilLoginDate, notReceivedExpiryInMinutes, moment.utc())) {
status = 'Incomplete'
}
} else if (isTrue(checkReceived) && isTrue(checkComplete) && isComplete(checkStatusCode) && isTrue(pupilCheckComplete)) {
status = 'Complete'
} else {
logger.error(`getProcessStatusV2(): ERROR: Unable to determine status for pupil [${pupilId}] arg was: \n` +
JSON.stringify(arg, ' ', 4))
}
return status
},
checkReceived,
checkStatusCode,
currentCheckId,
notReceivedExpiryInMinutes,
pinExpiresAt,
pupilCheckComplete,
pupilId,
pupilLoginDate,
restartAvailable
} = arg
if (pinExpiresAt && !moment.isMoment(pinExpiresAt)) {
throw new Error('pinExpiresAt must be null or a Moment.moment datetime')
}
if (isPositive(attendanceId)) {
status = 'Not taking the Check'
} else if (isTrue(restartAvailable)) {
status = 'Restart'
} else if ((isNil(currentCheckId) && isNil(checkStatusCode)) ||
(isPositive(currentCheckId) && isNew(checkStatusCode) &&
(isNil(pinExpiresAt) || isExpired(pinExpiresAt)))) {
status = 'Not started'
} else if (isPositive(currentCheckId) && isNew(checkStatusCode)) {
status = 'PIN generated'
} else if (isPositive(currentCheckId) && isCollected(checkStatusCode) && isFalse(checkReceived)) {
status = 'Logged in'
if (isNotReceived(pupilLoginDate, notReceivedExpiryInMinutes, moment.utc())) {
status = 'Incomplete'
}
} else if (isTrue(checkReceived) && isTrue(checkComplete) && isComplete(checkStatusCode) && isTrue(pupilCheckComplete)) {
status = 'Complete'