Undo breaking scheduling change.

This commit is contained in:
Patrick Fic
2021-10-25 10:36:27 -07:00
parent 7482751c5b
commit 0240065990

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,