Skip to content

Commit 96aed5e

Browse files
author
Trey Ivy
committed
format time on tests summary view
1 parent 688a18a commit 96aed5e

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

frontend/src/components/TestGrid/index.tsx

+18-4
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,25 @@ import { GetTestsWithOffsetQueryVariables } from '@/graphql/__generated__/graphq
1414
import TestGridRow from '../TestGridRow';
1515
import PortalAlert from '../PortalAlert';
1616
import Link from 'next/link';
17+
import styles from "../PortalDuration/index.module.css"
1718

1819
interface Props {
1920
//labelData: GetTestsWithOffsetQuery | undefined
2021
}
2122

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+
}
2236
const formatter: StatisticProps['formatter'] = (value) => (
2337
<CountUp end={value as number} separator="," />
2438
);
@@ -56,19 +70,19 @@ const columns: TableColumnsType<TestGridRowDataType> = [
5670
title: "Average Duration",
5771
dataIndex: "average_duration",
5872
//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>
6074
},
6175
{
6276
title: "Min Duration",
6377
dataIndex: "min_duration",
6478
//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>
6680
},
6781
{
6882
title: "Max Duration",
6983
dataIndex: "max_duration",
7084
//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>
7286
},
7387
{
7488
title: "Num Runs",
@@ -79,7 +93,7 @@ const columns: TableColumnsType<TestGridRowDataType> = [
7993
title: "Pass Rate",
8094
dataIndex: "pass_rate",
8195
//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) + "%"
8397
}
8498
]
8599

0 commit comments

Comments
 (0)