Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix graph displaying negative durations #52

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions frontend/src/app/trends/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import CountUp from 'react-countup';
const Page: React.FC = () => {

const [variables, setVariables] = useState<FindBuildTimesQueryVariables>({
first: 10000,
first: 1000,
});

const { loading, data, previousData, error } = useQuery(FIND_BUILD_DURATIONS, {
Expand Down Expand Up @@ -52,7 +52,11 @@ const Page: React.FC = () => {
to: x.endedAt,
duration: (new Date(x.endedAt).getTime() - new Date(x.startedAt).getTime())
}
dataPoints.push(point)
// if there are empty/nil dates they get set to max epoch start time
// which throws the graph off.
if (point.duration > 0) {
dataPoints.push(point)
}
});

const formatter: StatisticProps['formatter'] = (value) => (
Expand Down Expand Up @@ -84,14 +88,14 @@ const Page: React.FC = () => {
<PortalCard
type='inner'
icon={<ClockCircleFilled />}
titleBits={[<span>Invocation Durations <Badge count={data?.findBazelInvocations.totalCount} /> </span>]}>
titleBits={[<span>Invocation Durations</span>]}>
<Row>
<Space size="large">
<Statistic title="Total" value={data?.findBazelInvocations.totalCount} formatter={formatter} valueStyle={{ color: "#82ca9d" }} />
<Statistic title="Average" value={avg} formatter={formatter} valueStyle={{ color: "#82ca9d" }} />
<Statistic title="Median" value={median} formatter={formatter} valueStyle={{ color: "#8884d8" }} />
<Statistic title="Max" value={max} formatter={formatter} />
<Statistic title="Min" value={min} formatter={formatter} />

</Space>
</Row>
<Row>
Expand Down
Loading