Build output table sort (#5380)

* Implement sorting for "build output" column in build output table

* Implement sorting for the "required tests" column

* use isNan
This commit is contained in:
Oliver 2023-08-01 12:52:36 +10:00 committed by GitHub
parent 668dab4175
commit 7394ddae33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1295,6 +1295,44 @@ function loadBuildOutputTable(build_info, options={}) {
title: '{% trans "Build Output" %}',
switchable: false,
sortable: true,
sorter: function(fieldA, fieldB, rowA, rowB) {
let serialA = parseInt(rowA.serial);
let serialB = parseInt(rowB.serial);
// Fallback to string representation
if (isNaN(serialA)) {
serialA = rowA.serial;
} else if (isNaN(serialB)) {
serialB = rowB.serial;
}
if (serialA && !serialB) {
// Only rowA has a serial number
return 1;
} else if (serialB && !serialA) {
// Only rowB has a serial number
return -1;
} else if (serialA && serialB) {
// Both rows have serial numbers
if (serialA > serialB) {
return 1;
} else if (serialA < serialB) {
return -1;
} else {
return 0;
}
} else {
// Neither row has a serial number
if (rowA.quantity > rowB.quantity) {
return 1;
} else if (rowA.quantity < rowB.quantity) {
return -1;
} else {
return 0;
}
}
},
formatter: function(value, row) {
let text = '';
@ -1339,6 +1377,19 @@ function loadBuildOutputTable(build_info, options={}) {
title: '{% trans "Required Tests" %}',
visible: test_templates.length > 0,
switchable: true,
sortable: true,
sorter: function(valueA, valueB, rowA, rowB) {
let nA = getPassedTestCount(rowA);
let nB = getPassedTestCount(rowB);
if (nA > nB) {
return 1;
} else if (nA < nB) {
return -1;
} else {
return 0;
}
},
formatter: function(value, row) {
if (row.tests) {
return makeProgressBar(