Refactor sorting functions to prioritize effort and improve handling of undefined values
This commit is contained in:
@ -13,16 +13,32 @@ var _machineId = '';
|
||||
var _sessionId = '';
|
||||
var _windowLocationHRef = '';
|
||||
|
||||
function compareFunctionSortOrder(a: any, b: any) {
|
||||
return a.SortOrder - b.SortOrder;
|
||||
function compareFunctionEffort(a: any, b: any) {
|
||||
if (a.Effort == undefined || a.Effort === ' ') {
|
||||
return -1;
|
||||
}
|
||||
if (b.Effort !== a.Effort) {
|
||||
return b.Effort - a.Effort;
|
||||
}
|
||||
return b.WeightedShortestJobFirst - a.WeightedShortestJobFirst;
|
||||
}
|
||||
|
||||
function compareFunctionParentId(a: any, b: any) {
|
||||
return a.ParentId - b.ParentId || a.Id - b.Id;
|
||||
function compareFunctionSortOrder(a: any, b: any) {
|
||||
if (a.SortOrder == undefined || a.SortOrder === ' ') {
|
||||
return -1;
|
||||
}
|
||||
return a.SortOrder - b.SortOrder
|
||||
}
|
||||
|
||||
function compareFunctionWeightedShortestJobFirst(a: any, b: any) {
|
||||
if (b.WeightedShortestJobFirst === ' ') {
|
||||
if (b.WeightedShortestJobFirst == undefined || b.WeightedShortestJobFirst === ' ') {
|
||||
return -1;
|
||||
}
|
||||
return b.WeightedShortestJobFirst - a.WeightedShortestJobFirst;
|
||||
}
|
||||
|
||||
function compareFunctionWeightedShortestJobFirstNullFirst(a: any, b: any) {
|
||||
if (a.WeightedShortestJobFirst == undefined || a.WeightedShortestJobFirst === ' ') {
|
||||
return -1;
|
||||
}
|
||||
return b.WeightedShortestJobFirst - a.WeightedShortestJobFirst;
|
||||
@ -300,14 +316,17 @@ function getRecords(b: any, r: any, t: any, c: any, e: any, w: any, data: any, d
|
||||
workItem.State = getState(workItem.State);
|
||||
records.push(workItem);
|
||||
}
|
||||
if (_windowLocationHRef.indexOf('=WSJF') > -1) {
|
||||
records.sort(compareFunctionWeightedShortestJobFirst);
|
||||
if (_windowLocationHRef.indexOf('=EFFORT') > -1) {
|
||||
records.sort(compareFunctionEffort);
|
||||
}
|
||||
else if (_windowLocationHRef.indexOf('=LIVE') > -1) {
|
||||
records.sort(compareFunctionSortOrder);
|
||||
}
|
||||
else if (_windowLocationHRef.indexOf('=WSJF') > -1) {
|
||||
records.sort(compareFunctionWeightedShortestJobFirst);
|
||||
}
|
||||
else {
|
||||
records.sort(compareFunctionParentId);
|
||||
records.sort(compareFunctionWeightedShortestJobFirstNullFirst);
|
||||
}
|
||||
return records;
|
||||
}
|
||||
|
Reference in New Issue
Block a user