Skip to content

Commit

Permalink
table: fix dt-mean
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver-sanders committed Jan 4, 2023
1 parent 09c3827 commit e4e5206
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ New tabs now open on top.

### Fixes

[#1164](https://github.com/cylc/cylc-ui/pull/1164) -
Fix the mean run time column in the table view.

[#1108](https://github.com/cylc/cylc-ui/pull/1108) -
Tree view: Task outputs are now correctly associated with the jobs that created
them.
Expand Down
15 changes: 13 additions & 2 deletions src/components/cylc/table/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<td>{{ ((item.latestJob || {}).node || {}).submittedTime }}</td>
<td>{{ ((item.latestJob || {}).node || {}).startedTime }}</td>
<td>{{ ((item.latestJob || {}).node || {}).finishedTime }}</td>
<td>{{ item.task.node.meanElapsedTime }}</td>
<td>{{ dtMean(item.task) }}</td>
</tr>
</template>
<template v-slot:expanded-item="{ item }">
Expand Down Expand Up @@ -244,7 +244,7 @@ export default {
},
{
text: 'dT-mean',
value: 'task.meanElapsedTime',
value: 'task.node.task.meanElapsedTime',
sort: (a, b) => parseInt(a ?? 0) - parseInt(b ?? 0)
}
],
Expand All @@ -255,6 +255,17 @@ export default {
filteredTasks () {
return this.tasks.filter(({ task }) => matchNode(task.node, this.tasksFilter.name, this.tasksFilter.states))
}
},
methods: {
dtMean (taskNode) {
const ret = taskNode.node?.task?.meanElapsedTime
if (ret) {
return ret.toFixed()
}
// the meanElapsedTime can be undefined (e.g. task has not run before)
// return "undefined" rather than a number for these cases
return undefined
}
}
}
</script>
24 changes: 24 additions & 0 deletions tests/e2e/specs/table.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,29 @@ describe('Table view', () => {
.contains('eventually')
.should('be.visible')
})
it('displays and sorts dt-mean', () => {
cy.visit('/#/table/one')

cy
// sort dt-mean ascending
.get('[aria-label="dT-mean: Not sorted. Activate to sort ascending."] > :nth-child(1)')
.click()

// check 0 is at the top (1st row, 10th column)
.get('tbody > :nth-child(1) > :nth-child(10)')
.should(($ele) => {
expect($ele.text().trim()).equal('') // no value sorted first
})

// sort ft-mean descending
.get('.asc > .v-icon > .v-icon__svg > path')
.click()

// check 7 is at the top (1st row, 10th column)
.get('tbody > :nth-child(1) > :nth-child(10)')
.should(($ele) => {
expect($ele.text().trim()).equal('7')
})
})
})
})

0 comments on commit e4e5206

Please sign in to comment.