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 _sessionId = '';
|
||||||
var _windowLocationHRef = '';
|
var _windowLocationHRef = '';
|
||||||
|
|
||||||
function compareFunctionSortOrder(a: any, b: any) {
|
function compareFunctionEffort(a: any, b: any) {
|
||||||
return a.SortOrder - b.SortOrder;
|
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) {
|
function compareFunctionSortOrder(a: any, b: any) {
|
||||||
return a.ParentId - b.ParentId || a.Id - b.Id;
|
if (a.SortOrder == undefined || a.SortOrder === ' ') {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return a.SortOrder - b.SortOrder
|
||||||
}
|
}
|
||||||
|
|
||||||
function compareFunctionWeightedShortestJobFirst(a: any, b: any) {
|
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 -1;
|
||||||
}
|
}
|
||||||
return b.WeightedShortestJobFirst - a.WeightedShortestJobFirst;
|
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);
|
workItem.State = getState(workItem.State);
|
||||||
records.push(workItem);
|
records.push(workItem);
|
||||||
}
|
}
|
||||||
if (_windowLocationHRef.indexOf('=WSJF') > -1) {
|
if (_windowLocationHRef.indexOf('=EFFORT') > -1) {
|
||||||
records.sort(compareFunctionWeightedShortestJobFirst);
|
records.sort(compareFunctionEffort);
|
||||||
}
|
}
|
||||||
else if (_windowLocationHRef.indexOf('=LIVE') > -1) {
|
else if (_windowLocationHRef.indexOf('=LIVE') > -1) {
|
||||||
records.sort(compareFunctionSortOrder);
|
records.sort(compareFunctionSortOrder);
|
||||||
}
|
}
|
||||||
|
else if (_windowLocationHRef.indexOf('=WSJF') > -1) {
|
||||||
|
records.sort(compareFunctionWeightedShortestJobFirst);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
records.sort(compareFunctionParentId);
|
records.sort(compareFunctionWeightedShortestJobFirstNullFirst);
|
||||||
}
|
}
|
||||||
return records;
|
return records;
|
||||||
}
|
}
|
||||||
|
@ -13,16 +13,29 @@ var _machineId = '';
|
|||||||
var _sessionId = '';
|
var _sessionId = '';
|
||||||
var _windowLocationHRef = '';
|
var _windowLocationHRef = '';
|
||||||
|
|
||||||
function compareFunctionSortOrder(a, b) {
|
function compareFunctionEffort(a, b) {
|
||||||
return a.SortOrder - b.SortOrder;
|
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, b) {
|
function compareFunctionSortOrder(a, b) {
|
||||||
return a.ParentId - b.ParentId || a.Id - b.Id;
|
return a.SortOrder - b.SortOrder
|
||||||
}
|
}
|
||||||
|
|
||||||
function compareFunctionWeightedShortestJobFirst(a, b) {
|
function compareFunctionWeightedShortestJobFirst(a, b) {
|
||||||
if (b.WeightedShortestJobFirst === ' ') {
|
if (b.WeightedShortestJobFirst == undefined || b.WeightedShortestJobFirst === ' ') {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return b.WeightedShortestJobFirst - a.WeightedShortestJobFirst;
|
||||||
|
}
|
||||||
|
|
||||||
|
function compareFunctionWeightedShortestJobFirstNullFirst(a, b) {
|
||||||
|
if (a.WeightedShortestJobFirst == undefined || a.WeightedShortestJobFirst === ' ') {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return b.WeightedShortestJobFirst - a.WeightedShortestJobFirst;
|
return b.WeightedShortestJobFirst - a.WeightedShortestJobFirst;
|
||||||
@ -289,14 +302,17 @@ function getRecords(b, r, t, c, e, w, data, dataB, workItems) {
|
|||||||
workItem.State = getState(workItem.State);
|
workItem.State = getState(workItem.State);
|
||||||
records.push(workItem);
|
records.push(workItem);
|
||||||
}
|
}
|
||||||
if (_windowLocationHRef.indexOf('=WSJF') > -1) {
|
if (_windowLocationHRef.indexOf('=EFFORT') > -1) {
|
||||||
records.sort(compareFunctionWeightedShortestJobFirst);
|
records.sort(compareFunctionEffort);
|
||||||
}
|
}
|
||||||
else if (_windowLocationHRef.indexOf('=LIVE') > -1) {
|
else if (_windowLocationHRef.indexOf('=LIVE') > -1) {
|
||||||
records.sort(compareFunctionSortOrder);
|
records.sort(compareFunctionSortOrder);
|
||||||
}
|
}
|
||||||
|
else if (_windowLocationHRef.indexOf('=WSJF') > -1) {
|
||||||
|
records.sort(compareFunctionWeightedShortestJobFirst);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
records.sort(compareFunctionParentId);
|
records.sort(compareFunctionWeightedShortestJobFirstNullFirst);
|
||||||
}
|
}
|
||||||
return records;
|
return records;
|
||||||
}
|
}
|
||||||
@ -445,17 +461,17 @@ function updateSite(c, w) {
|
|||||||
document.title = document.title.replace('Infineon', 'Infineon');
|
document.title = document.title.replace('Infineon', 'Infineon');
|
||||||
document.getElementById('siteHeader').innerText = 'Infineon';
|
document.getElementById('siteHeader').innerText = 'Infineon';
|
||||||
}
|
}
|
||||||
if (_windowLocationHRef.indexOf('=WSJF') > -1) {
|
if (_windowLocationHRef.indexOf('=EFFORT') > -1) {
|
||||||
document.getElementById('th-span').innerHTML = w.th + ' sorted by WSJF';
|
document.getElementById('th-span').innerHTML = c.th + ' sorted by Effort (null, highest, ..., lowest)';
|
||||||
}
|
}
|
||||||
else if (_windowLocationHRef.indexOf('=LIVE') > -1) {
|
else if (_windowLocationHRef.indexOf('=LIVE') > -1) {
|
||||||
document.getElementById('th-span').innerHTML = c.th + ' sorted by CoD';
|
document.getElementById('th-span').innerHTML = c.th + ' Live View';
|
||||||
}
|
}
|
||||||
else if (_windowLocationHRef.indexOf('=EFFORT') > -1) {
|
else if (_windowLocationHRef.indexOf('=WSJF') > -1) {
|
||||||
document.getElementById('th-span').innerHTML = c.th + ' sorted by Parent Id';
|
document.getElementById('th-span').innerHTML = w.th + ' sorted by WSJF (highest, ..., lowest, null)';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
document.getElementById('th-span').innerHTML = c.th + ' sorted by Parent Id';
|
document.getElementById('th-span').innerHTML = c.th + ' sorted by WSJF (null, highest, ..., lowest)';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user