🐛 Fix ordering when auto refreshing (#1761)

* Fix ordering when auto refreshing

* Fix ordering for current executinos as well
This commit is contained in:
Omar Ajoue 2021-05-12 17:51:54 +02:00 committed by GitHub
parent c632f7982f
commit c739a498f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View file

@ -1732,6 +1732,7 @@ class App {
} }
); );
} }
returnData.sort((a, b) => parseInt(b.id, 10) - parseInt(a.id, 10));
return returnData; return returnData;
} }

View file

@ -438,7 +438,8 @@ export default mixins(
this.$store.commit('setActiveExecutions', results[1]); this.$store.commit('setActiveExecutions', results[1]);
const alreadyPresentExecutionIds = this.finishedExecutions.map(exec => exec.id); // execution IDs are typed as string, int conversion is necessary so we can order.
const alreadyPresentExecutionIds = this.finishedExecutions.map(exec => parseInt(exec.id, 10));
let lastId = 0; let lastId = 0;
const gaps = [] as number[]; const gaps = [] as number[];
for(let i = results[0].results.length - 1; i >= 0; i--) { for(let i = results[0].results.length - 1; i >= 0; i--) {
@ -459,7 +460,7 @@ export default mixins(
// Check new results from end to start // Check new results from end to start
// Add new items accordingly. // Add new items accordingly.
const executionIndex = alreadyPresentExecutionIds.indexOf(currentItem.id); const executionIndex = alreadyPresentExecutionIds.indexOf(currentId);
if (executionIndex !== -1) { if (executionIndex !== -1) {
// Execution that we received is already present. // Execution that we received is already present.
@ -477,7 +478,7 @@ export default mixins(
// Find the correct position to place this newcomer // Find the correct position to place this newcomer
let j; let j;
for (j = this.finishedExecutions.length - 1; j >= 0; j--) { for (j = this.finishedExecutions.length - 1; j >= 0; j--) {
if (currentItem.id < this.finishedExecutions[j].id) { if (currentId < parseInt(this.finishedExecutions[j].id, 10)) {
this.finishedExecutions.splice(j + 1, 0, currentItem); this.finishedExecutions.splice(j + 1, 0, currentItem);
break; break;
} }