Skip to content

Commit 42c2202

Browse files
authored
Merge pull request #15 from fga-eps-mds/christian/feat/US-006
feat: add github metrics and measures graphs
2 parents 281558c + a4b0ce9 commit 42c2202

File tree

3 files changed

+35
-17
lines changed

3 files changed

+35
-17
lines changed

src/pages/products/[product]/repositories/[repository]/Repository.tsx

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,17 +227,36 @@ const Repository: NextPageWithLayout = () => {
227227
height={60}
228228
alignItems="center"
229229
>
230-
<h2 style={{ color: '#113D4C', fontWeight: '500', fontSize: '25px' }}>Métricas</h2>
230+
<h2 style={{ color: '#113D4C', fontWeight: '500', fontSize: '25px' }}>Histórico de medidas</h2>
231231
</Box>
232232

233-
<GraphicChart key="sonargraph" title="Sonar" type="line" value="metrics" metricsSource='sonarqube' />
233+
<GraphicChart key="sonargraph-measure" title="Sonar" type="line" value="measures" collectionSource='sonarqube' />
234+
235+
<GraphicChart
236+
key="ghGraph-measure"
237+
title="Github"
238+
type="line"
239+
value="measures"
240+
collectionSource='github'
241+
/>
242+
243+
<Box
244+
display="flex"
245+
flexDirection="row"
246+
height={60}
247+
alignItems="center"
248+
>
249+
<h2 style={{ color: '#113D4C', fontWeight: '500', fontSize: '25px' }}>Histórico de métricas</h2>
250+
</Box>
251+
252+
<GraphicChart key="sonargraph" title="Sonar" type="line" value="metrics" collectionSource='sonarqube' />
234253

235254
<GraphicChart
236255
key="ghGraph"
237256
title="Github"
238257
type="line"
239258
value="metrics"
240-
metricsSource='github'
259+
collectionSource='github'
241260
/>
242261

243262
<Box marginY="12px">

src/shared/components/GraphicChart/GraphicChart.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ interface Prop {
2222
autoGrid?: boolean;
2323
addHistoricalTSQMI?: boolean;
2424
addCurrentGoal?: boolean;
25-
metricsSource?: 'github' | 'sonarqube'
25+
collectionSource?: 'github' | 'sonarqube'
2626
}
2727

2828
type formatFunctionType = {
@@ -44,14 +44,14 @@ const GraphicChart = ({
4444
autoGrid = false,
4545
addHistoricalTSQMI = false,
4646
addCurrentGoal = false,
47-
metricsSource,
47+
collectionSource,
4848
}: Prop) => {
4949
const {
5050
data: historical,
5151
error,
5252
isLoading,
5353
isEmpty
54-
} = useRequestValues({ type: valueType, value, addHistoricalTSQMI, addCurrentGoal, metricsSource });
54+
} = useRequestValues({ type: valueType, value, addHistoricalTSQMI, addCurrentGoal, collectionSource });
5555
const { hasKey } = useProductConfigFilterContext();
5656
const [showCharts, setShowCharts] = useState(false);
5757
const { currentProduct } = useProductContext();
@@ -78,7 +78,7 @@ const GraphicChart = ({
7878
() =>
7979
_.range(numLines).map((i) => ({
8080
...chartOption[type]({
81-
historical: _.filter(sliceHistorical(i), (item) => metricsSource === 'github' || hasKey(item.key)),
81+
historical: _.filter(sliceHistorical(i), (item) => collectionSource === 'github' || hasKey(item.key)),
8282
title: i === 0 ? title : '',
8383
isEmpty: isEmpty || error,
8484
redLimit: currentProduct?.gaugeRedLimit,

src/shared/hooks/useRequestValues.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ interface Props {
1313
value: 'characteristics' | 'subcharacteristics' | 'measures' | 'metrics';
1414
addHistoricalTSQMI?: boolean;
1515
addCurrentGoal?: boolean;
16-
metricsSource?: 'github' | 'sonarqube';
16+
collectionSource?: 'github' | 'sonarqube';
1717
}
1818

1919
export function useRequestValues({
2020
type,
2121
value,
2222
addHistoricalTSQMI = false,
2323
addCurrentGoal = false,
24-
metricsSource
24+
collectionSource,
2525
}: Props) {
2626
const { currentOrganization } = useOrganizationContext();
2727
const { currentProduct } = useProductContext();
@@ -80,23 +80,22 @@ export function useRequestValues({
8080
returnData.push(historicalTSQMI);
8181
}
8282

83-
if (returnData?.length && metricsSource) {
84-
if (metricsSource === 'github') {
83+
if (returnData?.length && collectionSource) {
84+
85+
if (collectionSource === 'github') {
8586
returnData = returnData.filter(
86-
(res: any) => res.key === 'ci_feedback_time' || res.key === 'closed_issues' || res.key === 'total_issues'
87+
(res: any) => (res.key === 'total_builds' || res.key === 'sum_ci_feedback_times' || res.key === 'resolved_issues' || res.key === 'total_issues') || res.key === 'ci_feedback_time' || res.key === 'team_throughput'
8788
);
8889
}
8990

90-
if (metricsSource === 'sonarqube') {
91+
if (collectionSource === 'sonarqube') {
9192
returnData = returnData.filter(
92-
(res: any) => res.key !== 'ci_feedback_time' && res.key !== 'closed_issues' && res.key !== 'total_issues'
93+
(res: any) => res.key !== 'total_builds' && res.key !== 'sum_ci_feedback_times' && res.key !== 'resolved_issues' && res.key !== 'total_issues' && res.key !== 'ci_feedback_time' && res.key !== 'team_throughput'
9394
);
94-
95-
console.log(returnData);
9695
}
9796
}
9897

99-
console.log(metricsSource, returnData);
98+
console.log(collectionSource, returnData);
10099
return {
101100
data: returnData,
102101
error,

0 commit comments

Comments
 (0)