IO-1446 Smart Schedule Blocked Day Fixes

This commit is contained in:
Patrick Fic
2021-10-21 11:42:05 -07:00
parent da08fc74f1
commit 6bcb5f2af5

View File

@@ -87,7 +87,10 @@ exports.job = async (req, res) => {
} else {
//remove the date from the possible list.
const appDate = moment(appointment.start).format("yyyy-MM-DD");
delete bucketMatrix[appDate];
bucketMatrix[appDate] = {
...bucketMatrix[appDate],
blocked: true,
};
}
});
@@ -125,7 +128,9 @@ exports.job = async (req, res) => {
const possibleDates = [];
const bucketMatrixKeys = Object.keys(bucketMatrix);
bucketMatrixKeys.forEach((bmkey) => {
const isShopOpen = workingdays[dayOfWeekMapper(moment(bmkey).day())];
const isShopOpen =
workingdays[dayOfWeekMapper(moment(bmkey).day())] &&
!bucketMatrix[bmkey].blocked;
if (
JobBucket.target > bucketMatrix[bmkey].in - bucketMatrix[bmkey].out &&
@@ -134,7 +139,11 @@ exports.job = async (req, res) => {
possibleDates.push(new Date(bmkey).toISOString().substr(0, 10));
});
res.json(possibleDates);
if (possibleDates.length < 6) {
res.json(possibleDates);
} else {
res.json(possibleDates.slice(0, 5));
}
} catch (error) {
logger.log("smart-scheduling-error", "ERROR", req.user.email, jobId, {
error,