Resolved blocked day scheduling issue in smart scheduling IO-478
This commit is contained in:
@@ -68,20 +68,26 @@ exports.job = async (req, res) => {
|
||||
|
||||
//Populate the jobs scheduled to come in.
|
||||
appointments.forEach((appointment) => {
|
||||
const jobHrs =
|
||||
appointment.job.joblines_aggregate.aggregate.sum.mod_lb_hrs;
|
||||
//Is the job in the same bucket?
|
||||
const appointmentBucket = ssbuckets.filter(
|
||||
(bucket) =>
|
||||
bucket.gte <= jobHrs && (!!bucket.lt ? bucket.lt > jobHrs : true)
|
||||
)[0];
|
||||
if (appointmentBucket.id === JobBucket.id) {
|
||||
//Theyre the same classification. Add it to the matrix.
|
||||
if (!appointment.block) {
|
||||
const jobHrs =
|
||||
appointment.job.joblines_aggregate.aggregate.sum.mod_lb_hrs;
|
||||
//Is the job in the same bucket?
|
||||
const appointmentBucket = ssbuckets.filter(
|
||||
(bucket) =>
|
||||
bucket.gte <= jobHrs && (!!bucket.lt ? bucket.lt > jobHrs : true)
|
||||
)[0];
|
||||
if (appointmentBucket.id === JobBucket.id) {
|
||||
//Theyre the same classification. Add it to the matrix.
|
||||
const appDate = moment(appointment.start).format("yyyy-MM-DD");
|
||||
bucketMatrix[appDate] = {
|
||||
...bucketMatrix[appDate],
|
||||
in: bucketMatrix[appDate].in + 1,
|
||||
};
|
||||
}
|
||||
} else {
|
||||
//remove the date from the possible list.
|
||||
const appDate = moment(appointment.start).format("yyyy-MM-DD");
|
||||
bucketMatrix[appDate] = {
|
||||
...bucketMatrix[appDate],
|
||||
in: bucketMatrix[appDate].in + 1,
|
||||
};
|
||||
delete bucketMatrix[appDate];
|
||||
}
|
||||
});
|
||||
|
||||
@@ -123,15 +129,6 @@ exports.job = async (req, res) => {
|
||||
possibleDates.push(new Date(bmkey).toISOString().substr(0, 10));
|
||||
});
|
||||
|
||||
//Temp
|
||||
// possibleDates.push(new Date());
|
||||
// possibleDates.push(new Date());
|
||||
// possibleDates.push(new Date());
|
||||
// possibleDates.push(new Date());
|
||||
// possibleDates.push(new Date());
|
||||
//Get a list of upcoming appointments
|
||||
//Get the config for each day
|
||||
|
||||
res.json(possibleDates);
|
||||
} catch (error) {
|
||||
console.log("error", error);
|
||||
|
||||
Reference in New Issue
Block a user