Smart Scheduling Updates.
This commit is contained in:
@@ -148,14 +148,14 @@ exports.job = async (req, res) => {
|
|||||||
|
|
||||||
//Propagate the expected load to each day.
|
//Propagate the expected load to each day.
|
||||||
const yesterday = moment().tz(timezone).subtract(1, "day");
|
const yesterday = moment().tz(timezone).subtract(1, "day");
|
||||||
const today = moment().tz(timezone).startOf("day");
|
const today = moment().tz(timezone);
|
||||||
|
|
||||||
const end = moment.max([
|
const end = moment.max([
|
||||||
...filteredArrJobs.map((a) => moment(a.scheduled_in).tz(timezone)),
|
...filteredArrJobs.map((a) => moment(a.scheduled_in).tz(timezone)),
|
||||||
...filteredCompJobs
|
...filteredCompJobs
|
||||||
.map((p) => moment(p.actual_completion || p.scheduled_completion).tz(timezone))
|
.map((p) => moment(p.actual_completion || p.scheduled_completion).tz(timezone))
|
||||||
.filter((p) => p.isValid() && p.isAfter(yesterday)),
|
.filter((p) => p.isValid() && p.isAfter(yesterday)),
|
||||||
moment().tz(timezone).add(5, "days"),
|
moment().tz(timezone).add(15, "days"),
|
||||||
]);
|
]);
|
||||||
const range = Math.round(moment.duration(end.diff(today)).asDays());
|
const range = Math.round(moment.duration(end.diff(today)).asDays());
|
||||||
for (var day = 0; day < range; day++) {
|
for (var day = 0; day < range; day++) {
|
||||||
@@ -199,7 +199,7 @@ exports.job = async (req, res) => {
|
|||||||
const possibleDates = [];
|
const possibleDates = [];
|
||||||
delete load.productionTotal;
|
delete load.productionTotal;
|
||||||
const loadKeys = Object.keys(load).sort((a, b) =>
|
const loadKeys = Object.keys(load).sort((a, b) =>
|
||||||
moment(a).tz(timezone).isAfter(moment(b).tz(timezone)) ? 1 : -1
|
moment(a).isAfter(moment(b)) ? 1 : -1
|
||||||
);
|
);
|
||||||
|
|
||||||
loadKeys.forEach((loadKey) => {
|
loadKeys.forEach((loadKey) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user