@@ -14,11 +14,25 @@ import { GetTestsWithOffsetQueryVariables } from '@/graphql/__generated__/graphq
14
14
import TestGridRow from '../TestGridRow' ;
15
15
import PortalAlert from '../PortalAlert' ;
16
16
import Link from 'next/link' ;
17
+ import styles from "../PortalDuration/index.module.css"
17
18
18
19
interface Props {
19
20
//labelData: GetTestsWithOffsetQuery | undefined
20
21
}
21
22
23
+ function millisecondsToTime ( milliseconds : number ) : string {
24
+ const totalSeconds = Math . floor ( milliseconds / 1000 ) ;
25
+ const hours = Math . floor ( totalSeconds / 3600 ) ;
26
+ const minutes = Math . floor ( ( totalSeconds % 3600 ) / 60 ) ;
27
+ const seconds = totalSeconds % 60 ;
28
+ const remainingMilliseconds = Math . floor ( milliseconds % 1000 ) ;
29
+
30
+ return `${ pad ( hours ) } :${ pad ( minutes ) } :${ pad ( seconds ) } :${ pad ( remainingMilliseconds , 3 ) } ` ;
31
+ }
32
+
33
+ function pad ( num : number , size : number = 2 ) : string {
34
+ return num . toString ( ) . padStart ( size , '0' ) ;
35
+ }
22
36
const formatter : StatisticProps [ 'formatter' ] = ( value ) => (
23
37
< CountUp end = { value as number } separator = "," />
24
38
) ;
@@ -56,19 +70,19 @@ const columns: TableColumnsType<TestGridRowDataType> = [
56
70
title : "Average Duration" ,
57
71
dataIndex : "average_duration" ,
58
72
//sorter: (a, b) => a.average_duration - b.average_duration,
59
- render : ( _ , record ) => record . average_duration . toFixed ( 0 )
73
+ render : ( _ , record ) => < span className = { styles . duration } > { millisecondsToTime ( record . average_duration ) } </ span >
60
74
} ,
61
75
{
62
76
title : "Min Duration" ,
63
77
dataIndex : "min_duration" ,
64
78
//sorter: (a, b) => a.average_duration - b.average_duration,
65
- render : ( _ , record ) => record . average_duration . toFixed ( 0 )
79
+ render : ( _ , record ) => < span className = { styles . duration } > { millisecondsToTime ( record . min_duration ) } </ span >
66
80
} ,
67
81
{
68
82
title : "Max Duration" ,
69
83
dataIndex : "max_duration" ,
70
84
//sorter: (a, b) => a.average_duration - b.average_duration,
71
- render : ( _ , record ) => record . average_duration . toFixed ( 0 )
85
+ render : ( _ , record ) => < span className = { styles . duration } > { millisecondsToTime ( record . max_duration ) } </ span >
72
86
} ,
73
87
{
74
88
title : "Num Runs" ,
@@ -79,7 +93,7 @@ const columns: TableColumnsType<TestGridRowDataType> = [
79
93
title : "Pass Rate" ,
80
94
dataIndex : "pass_rate" ,
81
95
//sorter: (a, b) => a.pass_rate - b.pass_rate,
82
- render : ( _ , record ) => record . pass_rate . toFixed ( 2 ) + "%"
96
+ render : ( _ , record ) => ( record . pass_rate * 100 ) . toFixed ( 2 ) + "%"
83
97
}
84
98
]
85
99
0 commit comments