Skip to content

Commit

Permalink
address performance issues w/passrate
Browse files Browse the repository at this point in the history
  • Loading branch information
Trey Ivy committed Jan 21, 2025
1 parent 98c3593 commit 1777043
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 117 deletions.
1 change: 1 addition & 0 deletions config/portal.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
grpcServers: [{
listenAddresses: [':8082'],
authenticationPolicy: { allow: {} },
maximumReceivedMessageSizeBytes: 10*1024*1024
}],
}
9 changes: 7 additions & 2 deletions frontend/src/app/targets/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import React from 'react';
import Content from '@/components/Content';
import PortalCard from '@/components/PortalCard';
import { Space } from 'antd';
import { Alert, Space } from 'antd';
import { DeploymentUnitOutlined } from '@ant-design/icons';
import TargetGrid from '@/components/Targets/TargetGrid';

Expand All @@ -14,7 +14,12 @@ const Page: React.FC = () => {
<Space direction="vertical" size="middle" style={{ display: 'flex' }}>
<PortalCard
icon={<DeploymentUnitOutlined />}
titleBits={[<span key="title">Targets Overview</span>]}>
extraBits={[<Alert
showIcon
message = "Search by label to further refine your result"
type = "info"
/>]}
titleBits={[<span key="title">Targets Overview </span>]}>
<TargetGrid />
</PortalCard>
</Space >
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/app/tests/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import React from 'react';
import Content from '@/components/Content';
import PortalCard from '@/components/PortalCard';
import { Space } from 'antd';
import { Alert, Space } from 'antd';
import { ExperimentFilled } from '@ant-design/icons';
import TestGrid from '@/components/TestGrid';

Expand All @@ -14,6 +14,11 @@ const Page: React.FC = () => {
<Space direction="vertical" size="middle" style={{ display: 'flex' }}>
<PortalCard
icon={<ExperimentFilled />}
extraBits={[<Alert
showIcon
message = "Search by label to further refine your result"
type = "info"
/>]}
titleBits={[<span key="title">Tests Overview</span>]}>
<TestGrid />
</PortalCard>
Expand Down
35 changes: 6 additions & 29 deletions frontend/src/components/Targets/TargetGrid/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useCallback, useState } from 'react';
import { TableColumnsType } from "antd/lib"
import { Space, Row, Statistic, Table, TableProps, TablePaginationConfig, Pagination } from 'antd';
import { Space, Row, Statistic, Table, TableProps, TablePaginationConfig, Pagination, Alert } from 'antd';
import { TestStatusEnum } from '../../TestStatusTag';
import type { StatisticProps } from "antd/lib";
import CountUp from 'react-countup';
Expand Down Expand Up @@ -32,13 +32,12 @@ interface TargetGridRowDataType {
min_duration: number;
max_duration: number;
total_count: number;
pass_rate: number;
status: TargetStatusType[];
}
const formatter: StatisticProps['formatter'] = (value) => (
<CountUp end={value as number} separator="," />
);
const PAGE_SIZE = 10
const PAGE_SIZE = 20
const columns: TableColumnsType<TargetGridRowDataType> = [
{
title: "Label",
Expand All @@ -56,53 +55,41 @@ const columns: TableColumnsType<TargetGridRowDataType> = [
{
title: "Average Duration",
dataIndex: "average_duration",
//sorter: (a, b) => a.average_duration - b.average_duration,
render: (_, record) => <span className={styles.numberFormat}>{millisecondsToTime(record.average_duration)}</span>
},
{
title: "Min Duration",
dataIndex: "min_duration",
//sorter: (a, b) => a.average_duration - b.average_duration,
render: (_, record) => <span className={styles.numberFormat}>{millisecondsToTime(record.min_duration)}</span>
},
{
title: "Max Duration",
dataIndex: "max_duration",
//sorter: (a, b) => a.average_duration - b.average_duration,
render: (_, record) => <span className={styles.numberFormat}>{millisecondsToTime(record.max_duration)}</span>
},
{
title: "# Runs",
dataIndex: "total_count",
align: "right",
render: (_, record) => <span className={styles.numberFormat}>{record.total_count}</span>,
//sorter: (a, b) => a.total_count - b.total_count,
},
{
title: "Pass Rate",
dataIndex: "pass_rate",
//sorter: (a, b) => a.pass_rate - b.pass_rate,
render: (_, record) => <span className={styles.numberFormat}> {(record.pass_rate * 100).toFixed(2)}%</span>
}
]

const TargetGrid: React.FC<Props> = () => {

const [variables, setVariables] = useState<GetTargetsWithOffsetQueryVariables>({})
const [variables, setVariables] = useState<GetTargetsWithOffsetQueryVariables>({ limit: 20})

const { loading: labelLoading, data: labelData, previousData: labelPreviousData, error: labelError } = useQuery(GET_TARGETS_DATA, {
variables: variables,
fetchPolicy: 'cache-and-network',
pollInterval: 300000
});

const data = labelLoading ? labelPreviousData : labelData;
var result: TargetGridRowDataType[] = []
var totalCnt: number = 0

if (labelError) {
<PortalAlert className="error" message="There was a problem communicating w/the backend server." />
} else {
totalCnt = data?.getTargetsWithOffset?.total ?? 0
data?.getTargetsWithOffset?.result?.map(dataRow => {
var row: TargetGridRowDataType = {
key: "target-grid-row-data-" + uniqueId(),
Expand All @@ -112,7 +99,6 @@ const TargetGrid: React.FC<Props> = () => {
min_duration: dataRow?.min ?? 0,
max_duration: dataRow?.max ?? 0,
total_count: dataRow?.count ?? 0,
pass_rate: dataRow?.passRate ?? 0
}
result.push(row)
})
Expand All @@ -127,19 +113,14 @@ const TargetGrid: React.FC<Props> = () => {
} else {
vars.label = ""
}
vars.limit = PAGE_SIZE
vars.offset = ((pagination.current ?? 1) - 1) * PAGE_SIZE;
setVariables(vars)
},
[variables],
);
return (
<Space direction="vertical" size="middle" style={{ display: 'flex' }}>
<Row>
<Space size="large">
<Statistic title="Targets" value={totalCnt} formatter={formatter} />
</Space>
</Row>

<Row>
<Table<TargetGridRowDataType>
columns={columns}
Expand All @@ -149,15 +130,11 @@ const TargetGrid: React.FC<Props> = () => {
expandable={{
indentSize: 100,
expandedRowRender: (record) => (
//TODO: dynamically determine number of buttons to display based on page width and pass that as first
<TargetGridRow rowLabel={record.label} first={20} reverseOrder={true} />
),
rowExpandable: (_) => true,
}}
pagination={{
total: totalCnt,
showSizeChanger: false,
}}
pagination = {false}
dataSource={result} />
</Row>
</Space>
Expand Down
27 changes: 8 additions & 19 deletions frontend/src/components/TestGrid/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ interface TestGridRowDataType {
status: TestStatusType[];
}

const PAGE_SIZE = 10
const PAGE_SIZE = 20
const columns: TableColumnsType<TestGridRowDataType> = [
{
title: "Label",
Expand Down Expand Up @@ -80,21 +80,15 @@ const columns: TableColumnsType<TestGridRowDataType> = [
render: (_, record) => <span className={styles.numberFormat}>{record.total_count}</span>,
//sorter: (a, b) => a.total_count - b.total_count,
},
{
title: "Pass Rate",
dataIndex: "pass_rate",
//sorter: (a, b) => a.pass_rate - b.pass_rate,
render: (_, record) => <span className={styles.numberFormat}> {(record.pass_rate * 100).toFixed(2)}%</span>
}
]

const TestGrid: React.FC<Props> = () => {

const [variables, setVariables] = useState<GetTestsWithOffsetQueryVariables>({})
const [variables, setVariables] = useState<GetTestsWithOffsetQueryVariables>({ limit: PAGE_SIZE})

const { loading: labelLoading, data: labelData, previousData: labelPreviousData, error: labelError } = useQuery(GET_TEST_GRID_DATA, {
variables: variables,
fetchPolicy: 'cache-and-network',
pollInterval: 300000
});

const data = labelLoading ? labelPreviousData : labelData;
Expand Down Expand Up @@ -136,12 +130,6 @@ const TestGrid: React.FC<Props> = () => {
);
return (
<Space direction="vertical" size="middle" style={{ display: 'flex' }}>
<Row>
<Space size="large">
<Statistic title="Test Targets" value={totalCnt} formatter={formatter} />
</Space>
</Row>

<Row>
<Table<TestGridRowDataType>
columns={columns}
Expand All @@ -156,10 +144,11 @@ const TestGrid: React.FC<Props> = () => {
),
rowExpandable: (_) => true,
}}
pagination={{
total: totalCnt,
showSizeChanger: false,
}}
pagination = {false}
// pagination={{
// total: totalCnt,
// showSizeChanger: false,
// }}
dataSource={result} />
</Row>
</Space>
Expand Down
70 changes: 4 additions & 66 deletions internal/graphql/custom.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1777043

Please sign in to comment.