Skip to content

Commit 894d93e

Browse files
authored
Merge pull request #260 from middlewarehq/GROW-1465
Update lead time calculation in PullRequestsTable
2 parents 691d8e1 + 5417d38 commit 894d93e

File tree

3 files changed

+3
-158
lines changed

3 files changed

+3
-158
lines changed

web-server/src/components/PRTable/PullRequestsTable.tsx

Lines changed: 2 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export const PullRequestsTable: FC<
7777
updateSortConf,
7878
conf,
7979
getCSV
80-
} = useTableSort(propPrs, { field: 'cycle_time', order: 'desc' });
80+
} = useTableSort(propPrs, { field: 'lead_time', order: 'desc' });
8181

8282
const filteredPrs = useMemo(() => {
8383
let prs = sortedPrs;
@@ -389,20 +389,10 @@ export const PullRequestsTable: FC<
389389
</Line>
390390
</TableCell>
391391
)}
392-
{enabledColumnsSet.has('cycle_time') && (
393-
<TableCell sx={{ p: CELL_PAD }}>
394-
<MiniCycleTimeStat
395-
cycle={pr.cycle_time}
396-
response={pr.first_response_time}
397-
rework={pr.rework_time}
398-
release={pr.merge_time}
399-
/>
400-
</TableCell>
401-
)}
402392
{enabledColumnsSet.has('lead_time_as_sum_of_parts') && (
403393
<TableCell sx={{ p: CELL_PAD }}>
404394
<MiniLeadTimeStat
405-
lead={pr.lead_time_as_sum_of_parts}
395+
lead={pr.lead_time}
406396
response={pr.first_response_time}
407397
commit={Math.max(0, pr.first_commit_to_open)}
408398
rework={pr.rework_time}
@@ -674,100 +664,6 @@ const PrMetaCell: FC<{ pr: PR }> = ({ pr }) => {
674664
);
675665
};
676666

677-
export const MiniCycleTimeCore: FC<
678-
{
679-
cycle?: number;
680-
response?: number;
681-
rework?: number;
682-
release?: number;
683-
} & BoxProps
684-
> = ({ cycle = 0, release = 0, response = 0, rework = 0, ...props }) => {
685-
const theme = useTheme();
686-
687-
const calcCycleTime = cycle || response + rework + release;
688-
689-
const defaultFlex = !calcCycleTime ? 1 : 0;
690-
691-
return (
692-
<Box
693-
display="flex"
694-
borderRadius={1 / 2}
695-
overflow="hidden"
696-
width="100%"
697-
flex={1}
698-
maxWidth="400px"
699-
{...props}
700-
>
701-
<Box
702-
bgcolor={brandColors.pr.firstResponseTime}
703-
color={theme.palette.background.default}
704-
fontWeight={700}
705-
py={1 / 2}
706-
pl={2}
707-
pr={3}
708-
minWidth={0}
709-
height="30px"
710-
display="flex"
711-
alignItems="center"
712-
justifyContent="center"
713-
whiteSpace="nowrap"
714-
flex={response || defaultFlex}
715-
sx={{
716-
clipPath: `polygon(0% 0%, calc(100% - 10px) 0%, 100% 50%, calc(100% - 10px) 100%, 0% 100%)`
717-
}}
718-
>
719-
{getDurationString(response || 0, {
720-
segments: response > secondsInDay ? 2 : 1
721-
}) || '-'}
722-
</Box>
723-
<Box
724-
bgcolor={brandColors.pr.reworkTime}
725-
color={theme.palette.background.default}
726-
fontWeight={700}
727-
mx={-1 / 2}
728-
py={1 / 2}
729-
px={3}
730-
minWidth={0}
731-
height="30px"
732-
display="flex"
733-
alignItems="center"
734-
justifyContent="center"
735-
whiteSpace="nowrap"
736-
flex={rework || defaultFlex}
737-
sx={{
738-
clipPath: `polygon(0% 0%, calc(100% - 10px) 0%, 100% 50%, calc(100% - 10px) 100%, 0% 100%, 10px 50%)`
739-
}}
740-
>
741-
{getDurationString(rework || 0, {
742-
segments: rework > secondsInDay ? 2 : 1
743-
}) || '-'}
744-
</Box>
745-
<Box
746-
bgcolor={brandColors.pr.mergeTime}
747-
color={theme.palette.background.default}
748-
fontWeight={700}
749-
py={1 / 2}
750-
pl={3}
751-
pr={2}
752-
minWidth={0}
753-
height="30px"
754-
display="flex"
755-
alignItems="center"
756-
justifyContent="center"
757-
whiteSpace="nowrap"
758-
flex={release || defaultFlex}
759-
sx={{
760-
clipPath: `polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%, 10px 50%)`
761-
}}
762-
>
763-
{getDurationString(release || 0, {
764-
segments: release > secondsInDay ? 2 : 1
765-
}) || '-'}
766-
</Box>
767-
</Box>
768-
);
769-
};
770-
771667
export const MiniLeadTimeCore: FC<
772668
{
773669
lead?: number;
@@ -1000,37 +896,6 @@ export const MiniCycleTimeLabels = ({
1000896
);
1001897
};
1002898

1003-
export const MiniCycleTimeStat: FC<{
1004-
cycle?: number;
1005-
response?: number;
1006-
rework?: number;
1007-
release?: number;
1008-
}> = ({ cycle = 0, release = 0, response = 0, rework = 0 }) => {
1009-
const calcCycleTime = response + rework + release;
1010-
1011-
return (
1012-
<FlexBox
1013-
alignCenter
1014-
gap1
1015-
darkTip
1016-
title={
1017-
<>
1018-
<MiniCycleTimeCore
1019-
cycle={cycle}
1020-
release={release}
1021-
response={response}
1022-
rework={rework}
1023-
mb={1}
1024-
/>
1025-
<MiniCycleTimeLabels />
1026-
</>
1027-
}
1028-
tooltipPlacement="left"
1029-
>
1030-
<CycleTimePill time={calcCycleTime || cycle} />
1031-
</FlexBox>
1032-
);
1033-
};
1034899

1035900
export const MiniLeadTimeStat: FC<{
1036901
lead?: number;
@@ -1083,14 +948,6 @@ export const MiniLeadTimeStat: FC<{
1083948
>
1084949
<CycleTimePill
1085950
time={lead}
1086-
sx={{
1087-
color:
1088-
missingState === 'TOTAL'
1089-
? 'error.main'
1090-
: missingState === 'PARTIAL'
1091-
? 'warning.main'
1092-
: undefined
1093-
}}
1094951
/>
1095952
</FlexBox>
1096953
);

web-server/src/components/PRTable/PullRequestsTableHead.tsx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -266,17 +266,6 @@ export const PullRequestsTableHead: FC<PullRequestsTableHeadProps> = ({
266266
</TableSortLabel>
267267
</TableCell>
268268
)}
269-
{enabledColumnsSet.has('cycle_time') && (
270-
<TableCell sx={{ p: CELL_PAD, py: 1.5 }}>
271-
<TableSortLabel
272-
direction={conf.field === 'cycle_time' ? conf.order : 'asc'}
273-
active={conf.field === 'cycle_time'}
274-
onClick={() => updateSortConf('cycle_time')}
275-
>
276-
Cycle <ClockIcon />
277-
</TableSortLabel>
278-
</TableCell>
279-
)}
280269
{enabledColumnsSet.has('lead_time_as_sum_of_parts') && (
281270
<TableCell sx={{ p: CELL_PAD, py: 1.5 }}>
282271
<TableSortLabel

web-server/src/slices/app.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@ export const DEFAULT_PR_TABLE_COLUMN_STATE_MAP = {
5656
first_response_time: false,
5757
rework_time: false,
5858
merge_time: false,
59-
cycle_time: true,
6059
merge_to_deploy: false,
61-
lead_time_as_sum_of_parts: false,
60+
lead_time_as_sum_of_parts: true,
6261
created_at: false,
6362
updated_at: false,
6463
head_branch: false,

0 commit comments

Comments
 (0)