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

feat(workflow): Group team alerts triggered by week (WOR-1407) #29026

Merged
merged 3 commits into from
Oct 4, 2021
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
29 changes: 18 additions & 11 deletions static/app/views/teamInsights/teamAlertsTriggered.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import styled from '@emotion/styled';
import moment from 'moment';
import chunk from 'lodash/chunk';

import AsyncComponent from 'app/components/asyncComponent';
import BarChart from 'app/components/charts/barChart';
Expand Down Expand Up @@ -72,31 +72,38 @@ class TeamIssues extends AsyncComponent<Props, State> {

renderBody() {
const {alertsTriggered} = this.state;
const data = Object.entries(alertsTriggered ?? {})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of data identifier is not clear, can we elaborate on the identifier e.g alertData

.map(([bucket, count]) => ({
value: count,
name: new Date(bucket).getTime(),
}))
.sort((a, b) => a.name - b.name);

// Convert from days to 7 day groups
const seriesData = chunk(data, 7).map(week => {
return {
name: week[0].name,
value: week.reduce((total, currentData) => total + currentData.value, 0),
};
});

return (
<ChartWrapper>
{alertsTriggered && (
<BarChart
style={{height: 190}}
isGroupedByDate
useShortDate
period="7d"
legend={{right: 0, top: 0}}
yAxis={{minInterval: 1}}
xAxis={{
type: 'time',
axisTick: {
alignWithLabel: true,
},
axisLabel: {
formatter: (value: number) => moment(new Date(value)).format('MMM D'),
},
}}
series={[
{
seriesName: t('Alerts Triggered'),
data: Object.entries(alertsTriggered).map(([bucket, count]) => ({
value: count,
name: bucket,
})),
data: seriesData,
},
].reverse()}
/>
Expand Down