Reconfigured smart scheduling to use buckets instead of load.
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import _ from "lodash";
|
||||
|
||||
export const CheckJobBucket = (buckets, job) => {
|
||||
const jobHours =
|
||||
job.labhrs.aggregate.sum.mod_lb_hrs + job.larhrs.aggregate.sum.mod_lb_hrs;
|
||||
|
||||
const matchingBucket = buckets.filter(
|
||||
(b) => b.gte <= jobHours && b.lt > jobHours
|
||||
const matchingBucket = buckets.filter((b) =>
|
||||
b.gte <= jobHours && b.lt ? b.lt > jobHours : true
|
||||
);
|
||||
|
||||
return matchingBucket[0] && matchingBucket[0].id;
|
||||
@@ -11,7 +13,7 @@ export const CheckJobBucket = (buckets, job) => {
|
||||
|
||||
export const CalculateLoad = (currentLoad, buckets, jobsIn, jobsOut) => {
|
||||
//Add the jobs coming
|
||||
const newLoad = { ...currentLoad };
|
||||
const newLoad = _.cloneDeep(currentLoad);
|
||||
jobsIn.forEach((job) => {
|
||||
const bucketId = CheckJobBucket(buckets, job);
|
||||
if (bucketId) {
|
||||
@@ -30,13 +32,11 @@ export const CalculateLoad = (currentLoad, buckets, jobsIn, jobsOut) => {
|
||||
newLoad[bucketId].count = newLoad[bucketId].count - 1;
|
||||
} else {
|
||||
console.log(
|
||||
"[Util Arr Job]Uh oh, this job doesn't fit in a bucket!",
|
||||
"[Util Out Job]Uh oh, this job doesn't fit in a bucket!",
|
||||
job
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
console.log("newLoad", newLoad);
|
||||
|
||||
return newLoad;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user