File tree Expand file tree Collapse file tree 5 files changed +96
-11
lines changed Expand file tree Collapse file tree 5 files changed +96
-11
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,13 @@ creating a new release entry be sure to copy & paste the span tag with the
11
11
updated. Only the first match gets replaced, so it's fine to leave the old
12
12
ones in. -->
13
13
14
+ ## __ cylc-ui-1.5.0 (<span actions:bind =' release-date ' >Released 2023-01-16</span >)__
15
+
16
+ ### Enhancements
17
+
18
+ [ #1184 ] ( https://github.com/cylc/cylc-ui/pull/1184 ) - Mean times for tasks
19
+ in table changed to human readable ISO duration format.
20
+
14
21
## __ cylc-ui-1.4.0 (<span actions:bind =' release-date ' >Released 2023-01-16</span >)__
15
22
16
23
### Enhancements
Original file line number Diff line number Diff line change @@ -169,6 +169,7 @@ import { DEFAULT_COMPARATOR } from '@/components/cylc/common/sort'
169
169
import { datetimeComparator } from ' @/components/cylc/table/sort'
170
170
import { matchNode } from ' @/components/cylc/common/filter'
171
171
import TaskFilter from ' @/components/cylc/TaskFilter.vue'
172
+ import { dtMean } from ' @/utils/tasks'
172
173
173
174
export default {
174
175
name: ' TableComponent' ,
@@ -257,15 +258,7 @@ export default {
257
258
}
258
259
},
259
260
methods: {
260
- dtMean (taskNode ) {
261
- const ret = taskNode .node ? .task ? .meanElapsedTime
262
- if (ret) {
263
- return ret .toFixed ()
264
- }
265
- // the meanElapsedTime can be undefined (e.g. task has not run before)
266
- // return "undefined" rather than a number for these cases
267
- return undefined
268
- }
261
+ dtMean
269
262
}
270
263
}
271
264
< / script>
Original file line number Diff line number Diff line change @@ -105,3 +105,27 @@ export {
105
105
latestJob ,
106
106
jobMessageOutputs
107
107
}
108
+
109
+ export function dtMean ( taskNode ) {
110
+ // Convert to an easily read duration format:
111
+ const dur = taskNode . node ?. task ?. meanElapsedTime
112
+ if ( dur ) {
113
+ const seconds = dur % 60
114
+ const minutes = ( ( dur - seconds ) / 60 ) % 60
115
+ const hours = ( ( dur - minutes * 60 - seconds ) / 3600 ) % 24
116
+ const days = ( dur - hours * 3600 - minutes * 60 - seconds ) / 86400
117
+
118
+ let dayss = ''
119
+ if ( days > 0 ) {
120
+ dayss = days . toString ( ) + 'd '
121
+ }
122
+
123
+ return dayss +
124
+ hours . toString ( ) . padStart ( 2 , '0' ) +
125
+ ':' + minutes . toString ( ) . padStart ( 2 , '0' ) +
126
+ ':' + Math . round ( seconds ) . toString ( ) . padStart ( 2 , '0' )
127
+ }
128
+ // the meanElapsedTime can be 0/undefined (i.e. task has not run before)
129
+ // return "undefined" rather than a number for these cases
130
+ return undefined
131
+ }
Original file line number Diff line number Diff line change @@ -137,7 +137,7 @@ describe('Table view', () => {
137
137
// check 7 is at the top (1st row, 10th column)
138
138
. get ( 'tbody > :nth-child(1) > :nth-child(10)' )
139
139
. should ( ( $ele ) => {
140
- expect ( $ele . text ( ) . trim ( ) ) . equal ( '7 ' )
140
+ expect ( $ele . text ( ) . trim ( ) ) . equal ( '00:00:07 ' )
141
141
} )
142
142
} )
143
143
} )
Original file line number Diff line number Diff line change 17
17
18
18
import { expect } from 'chai'
19
19
import TaskState from '@/model/TaskState.model'
20
- import { extractGroupState , latestJob } from '@/utils/tasks'
20
+ import { dtMean , extractGroupState , latestJob } from '@/utils/tasks'
21
21
22
22
describe ( 'tasks' , ( ) => {
23
23
describe ( 'extractGroupState' , ( ) => {
@@ -90,4 +90,65 @@ describe('tasks', () => {
90
90
} )
91
91
} )
92
92
} )
93
+ describe ( 'dtMean' , ( ) => {
94
+ it ( 'should format seconds to nice isodatetime format' , ( ) => {
95
+ const tests = [
96
+ {
97
+ taskNode : { node : null } ,
98
+ expected : undefined
99
+ } ,
100
+ {
101
+ taskNode : {
102
+ task : {
103
+ meanElapsedTime : 0
104
+ }
105
+ } ,
106
+ expected : undefined
107
+ } ,
108
+ {
109
+ taskNode : {
110
+ node : {
111
+ task : {
112
+ meanElapsedTime : 84
113
+ }
114
+ }
115
+ } ,
116
+ expected : '00:01:24'
117
+ } ,
118
+ {
119
+ taskNode : {
120
+ node : {
121
+ task : {
122
+ meanElapsedTime : 42
123
+ }
124
+ }
125
+ } ,
126
+ expected : '00:00:42'
127
+ } ,
128
+ {
129
+ taskNode : {
130
+ node : {
131
+ task : {
132
+ meanElapsedTime : 4242
133
+ }
134
+ }
135
+ } ,
136
+ expected : '01:10:42'
137
+ } ,
138
+ {
139
+ taskNode : {
140
+ node : {
141
+ task : {
142
+ meanElapsedTime : 1426332
143
+ }
144
+ }
145
+ } ,
146
+ expected : '16d 12:12:12'
147
+ }
148
+ ]
149
+ tests . forEach ( test => {
150
+ expect ( dtMean ( test . taskNode ) ) . to . equal ( test . expected )
151
+ } )
152
+ } )
153
+ } )
93
154
} )
You can’t perform that action at this time.
0 commit comments