Refactor sorting functions to prioritize effort and improve handling of undefined values

This commit is contained in:
2025-10-20 17:53:31 -07:00
parent 94215def9c
commit 9e0499a73e
2 changed files with 57 additions and 22 deletions

View File

@ -13,16 +13,29 @@ var _machineId = '';
var _sessionId = '';
var _windowLocationHRef = '';
function compareFunctionSortOrder(a, b) {
return a.SortOrder - b.SortOrder;
function compareFunctionEffort(a, b) {
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) {
return a.ParentId - b.ParentId || a.Id - b.Id;
function compareFunctionSortOrder(a, b) {
return a.SortOrder - b.SortOrder
}
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 b.WeightedShortestJobFirst - a.WeightedShortestJobFirst;
@ -289,14 +302,17 @@ function getRecords(b, r, t, c, e, w, data, dataB, workItems) {
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;
}
@ -445,17 +461,17 @@ function updateSite(c, w) {
document.title = document.title.replace('Infineon', 'Infineon');
document.getElementById('siteHeader').innerText = 'Infineon';
}
if (_windowLocationHRef.indexOf('=WSJF') > -1) {
document.getElementById('th-span').innerHTML = w.th + ' sorted by WSJF';
if (_windowLocationHRef.indexOf('=EFFORT') > -1) {
document.getElementById('th-span').innerHTML = c.th + ' sorted by Effort (null, highest, ..., lowest)';
}
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) {
document.getElementById('th-span').innerHTML = c.th + ' sorted by Parent Id';
else if (_windowLocationHRef.indexOf('=WSJF') > -1) {
document.getElementById('th-span').innerHTML = w.th + ' sorted by WSJF (highest, ..., lowest, null)';
}
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)';
}
}