@@ -9,20 +9,12 @@ import _ from "lodash";
9
9
* Calculate execution time of an entry with timer field
10
10
*/
11
11
function calcExecutionTime ( entry ) {
12
- let elapsed = null ;
12
+ let elapsed = 0 ;
13
13
if ( entry . timer && entry . timer . run ) {
14
- // TODO: remove the else branch after Aug. 1 2024
15
- if ( Array . isArray ( entry . timer . run ) && ! _ . isEmpty ( entry . timer . run ) ) {
16
- elapsed = 0 ;
17
- entry . timer . run . forEach ( ( interval ) => {
18
- elapsed +=
14
+ entry . timer . run . forEach ( ( interval ) => {
15
+ elapsed +=
19
16
timeToTimestamp ( interval . end ) - timeToTimestamp ( interval . start ) ;
20
- } ) ;
21
- } else {
22
- elapsed =
23
- timeToTimestamp ( entry . timer . run . end ) -
24
- timeToTimestamp ( entry . timer . run . start ) ;
25
- }
17
+ } ) ;
26
18
}
27
19
return elapsed ;
28
20
}
@@ -36,7 +28,7 @@ function calcElapsedTime(timerField) {
36
28
elapsed = 0 ;
37
29
timerField . forEach ( ( interval ) => {
38
30
elapsed +=
39
- timeToTimestamp ( interval . end ) - timeToTimestamp ( interval . start ) ;
31
+ timeToTimestamp ( interval . end ) - timeToTimestamp ( interval . start ) ;
40
32
} ) ;
41
33
}
42
34
return elapsed < 0 ? null : elapsed ;
@@ -168,12 +160,14 @@ function formatSeconds(durationInSeconds) {
168
160
* @returns {string }
169
161
*/
170
162
function formatMilliseconds ( durationInMilliseconds ) {
171
- if ( ! _ . isNumber ( durationInMilliseconds ) ) { return "na" ; } ;
163
+ if ( ! _ . isNumber ( durationInMilliseconds ) ) {
164
+ return "na" ;
165
+ }
172
166
173
167
let secondsInMilliseconds = durationInMilliseconds % 60000 ;
174
168
let seconds = secondsInMilliseconds / 1000 ;
175
- let minutesInMilliseconds = ( durationInMilliseconds - secondsInMilliseconds )
176
- / 60000 ;
169
+ let minutesInMilliseconds =
170
+ ( durationInMilliseconds - secondsInMilliseconds ) / 60000 ;
177
171
let minutes = minutesInMilliseconds % 60 ;
178
172
let hours = ( minutesInMilliseconds - minutes ) / 60 ;
179
173
@@ -185,13 +179,11 @@ function formatMilliseconds(durationInMilliseconds) {
185
179
let secondsDisplay = seconds . toFixed ( 3 ) + "s" ;
186
180
187
181
return (
188
- [ hoursDisplay , minutesDisplay , secondsDisplay ]
189
- . filter ( Boolean )
190
- . join ( " " ) || "0s"
182
+ [ hoursDisplay , minutesDisplay , secondsDisplay ] . filter ( Boolean ) . join ( " " ) ||
183
+ "0s"
191
184
) ;
192
185
}
193
186
194
-
195
187
/**
196
188
* Formats the input number representing milliseconds into a string
197
189
* with format H:m:s.SSS. Each value is displayed only if it is greater
@@ -200,14 +192,16 @@ function formatMilliseconds(durationInMilliseconds) {
200
192
* @returns {string }
201
193
*/
202
194
function formatShortDuration ( durationInMilliseconds ) {
203
- if ( ! _ . isNumber ( durationInMilliseconds ) ) { return "na" ; } ;
195
+ if ( ! _ . isNumber ( durationInMilliseconds ) ) {
196
+ return "na" ;
197
+ }
204
198
205
199
durationInMilliseconds = _ . round ( durationInMilliseconds , - 2 ) ;
206
200
207
201
let secondsInMilliseconds = durationInMilliseconds % 60000 ;
208
202
let seconds = secondsInMilliseconds / 1000 ;
209
- let minutesInMilliseconds = ( durationInMilliseconds - secondsInMilliseconds )
210
- / 60000 ;
203
+ let minutesInMilliseconds =
204
+ ( durationInMilliseconds - secondsInMilliseconds ) / 60000 ;
211
205
let minutes = minutesInMilliseconds % 60 ;
212
206
let hours = ( minutesInMilliseconds - minutes ) / 60 ;
213
207
@@ -219,19 +213,17 @@ function formatShortDuration(durationInMilliseconds) {
219
213
let hoursDisplay = isDisplayedHours ? hours + "h" : "" ;
220
214
let minutesDisplay = isDisplayedMinutes ? minutes + "m" : "" ;
221
215
let secondsDisplay = isDisplayedSeconds
222
- ? isDisplayedMilliseconds
223
- ? seconds . toFixed ( 1 ) + "s"
224
- : seconds . toFixed ( 0 ) + "s"
225
- : null ;
216
+ ? isDisplayedMilliseconds
217
+ ? seconds . toFixed ( 1 ) + "s"
218
+ : seconds . toFixed ( 0 ) + "s"
219
+ : null ;
226
220
227
221
return (
228
- [ hoursDisplay , minutesDisplay , secondsDisplay ]
229
- . filter ( Boolean )
230
- . join ( ":" ) || "0s"
222
+ [ hoursDisplay , minutesDisplay , secondsDisplay ] . filter ( Boolean ) . join ( ":" ) ||
223
+ "0s"
231
224
) ;
232
225
}
233
226
234
-
235
227
export {
236
228
calcExecutionTime ,
237
229
calcElapsedTime ,
@@ -436,15 +428,15 @@ export const truncateString = (
436
428
str ,
437
429
maxLength = 15 ,
438
430
startLength = 7 ,
439
- endLength = 7
431
+ endLength = 7
440
432
) => {
441
433
if ( str . length <= maxLength ) {
442
434
return str ;
443
435
}
444
436
445
437
const startPortion = str . slice ( 0 , startLength ) ;
446
438
const endPortion = str . slice ( - 1 * endLength ) ;
447
-
439
+
448
440
return `${ startPortion } ...${ endPortion } ` ;
449
441
} ;
450
442
@@ -453,7 +445,7 @@ export const truncateString = (
453
445
* @param {String } path
454
446
*/
455
447
export const getWorkspacePath = ( path ) => {
456
- const srcIndex = path . indexOf ( ' /src/' ) ;
448
+ const srcIndex = path . indexOf ( " /src/" ) ;
457
449
458
450
if ( srcIndex !== - 1 ) {
459
451
return path . slice ( srcIndex + 1 ) ;
0 commit comments