Skip to content

Commit 78cb8c8

Browse files
committed
Added display of values in the average
1 parent ab3489a commit 78cb8c8

File tree

3 files changed

+91
-29
lines changed

3 files changed

+91
-29
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import React from 'react';
2+
3+
import { withStyles, Theme } from '@material-ui/core/styles';
4+
import Typography from '@material-ui/core/Typography';
5+
import Tooltip from '@material-ui/core/Tooltip';
6+
7+
import Table from '@material-ui/core/Table';
8+
import TableBody from '@material-ui/core/TableBody';
9+
import TableContainer from '@material-ui/core/TableContainer';
10+
import TableHead from '@material-ui/core/TableHead';
11+
import TableRow from '@material-ui/core/TableRow';
12+
import TableCell from '@material-ui/core/TableCell';
13+
14+
interface Props {
15+
data: any;
16+
}
17+
18+
const HtmlTooltip = withStyles((theme: Theme) => ({
19+
tooltip: {
20+
backgroundColor: '#fff',
21+
color: 'rgba(0, 0, 0, 0.87)',
22+
maxWidth: 800,
23+
fontSize: theme.typography.pxToRem(10),
24+
border: '1px solid #dadde9',
25+
},
26+
}))(Tooltip);
27+
28+
const CompareCell: React.FC<Props> = (props: Props) => {
29+
const { data } = props;
30+
31+
return (
32+
<TableCell align="right">
33+
<HtmlTooltip
34+
title={
35+
<React.Fragment>
36+
<Typography color="inherit">Average calculated using:</Typography>
37+
<TableContainer>
38+
<Table size="small" aria-label="a dense table">
39+
<TableHead>
40+
<TableRow>
41+
<TableCell>Run Name</TableCell>
42+
<TableCell>Started</TableCell>
43+
<TableCell align="right">Value</TableCell>
44+
</TableRow>
45+
</TableHead>
46+
<TableBody>
47+
{data.runs.map((run: any) => (
48+
<TableRow key={run.id}>
49+
<TableCell>{run.name}</TableCell>
50+
<TableCell>{run.startedAt}</TableCell>
51+
<TableCell align="right">{Math.round(run.value)}</TableCell>
52+
</TableRow>
53+
))}
54+
</TableBody>
55+
</Table>
56+
</TableContainer>
57+
</React.Fragment>
58+
}
59+
>
60+
<span>{Math.round(data.value)}</span>
61+
</HtmlTooltip>
62+
</TableCell>
63+
);
64+
};
65+
66+
export default CompareCell;

src/views/testingPerfs/content/compare/comparisonTable/getData.graphql

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,12 @@ query($query: String, $referenceQuery: String, $comparisonQuery: String, $select
3737
statisticsKey
3838
transaction
3939
value
40-
}
41-
values {
42-
id
43-
name
44-
startedAt
45-
statisticsKey
46-
transaction
47-
value
40+
runs {
41+
id
42+
name
43+
startedAt
44+
value
45+
}
4846
}
4947
}
5048
comparison: average(profileId: $selectedProfile, averageQuery: $comparisonQuery) {
@@ -83,14 +81,12 @@ query($query: String, $referenceQuery: String, $comparisonQuery: String, $select
8381
statisticsKey
8482
transaction
8583
value
86-
}
87-
values {
88-
id
89-
name
90-
startedAt
91-
statisticsKey
92-
transaction
93-
value
84+
runs {
85+
id
86+
name
87+
startedAt
88+
value
89+
}
9490
}
9591
}
9692
}

src/views/testingPerfs/content/compare/comparisonTable/index.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import IconButton from '@material-ui/core/IconButton';
1919

2020
import { iRootState } from '../../../../../store';
2121
import CustomCard from '../../../../../components/customCard';
22+
import CompareCell from './compareCell';
2223

2324
const mapState = (state: iRootState) => ({
2425
query: state.testingPerfs.query,
@@ -259,37 +260,36 @@ const ComparisonTable: React.FC<connectedProps> = (props: connectedProps) => {
259260
{comparisonTableColumns
260261
.filter((c: any) => c.visible === true)
261262
.map((col: any) => {
262-
let refValue = reference.average.find(
263+
const refValue = reference.average.find(
263264
(v: any) => v.transaction === transaction && v.statisticsKey === col.id,
264265
);
265-
refValue = refValue !== undefined ? refValue.value : '';
266-
let compValue = comparison.average.find(
266+
const compValue = comparison.average.find(
267267
(v: any) => v.transaction === transaction && v.statisticsKey === col.id,
268268
);
269-
compValue = compValue !== undefined ? compValue.value : '';
270269
let compDiff: number | string = 0;
271-
if (refValue === '' || compValue === '') {
270+
if (refValue.value === undefined || compValue.value === undefined) {
272271
compDiff = '';
273-
} else if (refValue === 0 && compValue === 0) {
272+
} else if (refValue.value === 0 && compValue.value === 0) {
274273
compDiff = 0;
275-
} else if (compValue === 0) {
276-
compDiff = refValue;
274+
} else if (compValue.value === 0) {
275+
compDiff = refValue.value;
277276
} else {
278-
compDiff = 1 - refValue / compValue;
277+
compDiff = 1 - refValue.value / compValue.value;
279278
}
280279
return {
281280
...col,
282-
refValue: refValue === '' ? '' : Math.round(refValue),
283-
compValue: compValue === '' ? '' : Math.round(compValue),
281+
refAverage: refValue,
282+
compAverage: compValue,
284283
compDiff: compDiff,
285284
};
286285
})
287286
.map((col: any) => (
288287
<React.Fragment key={col.id}>
289-
<TableCell align="right">{col.refValue}</TableCell>
288+
{/* <TableCell align="right">{Math.round(col.refAverage.value)}</TableCell> */}
289+
<CompareCell data={col.refAverage} />
290290
{!comparisonTableHideCompare && (
291291
<>
292-
<TableCell align="right">{col.compValue}</TableCell>
292+
<CompareCell data={col.compAverage} />
293293
<TableCell
294294
align="right"
295295
style={{

0 commit comments

Comments
 (0)