Skip to content

Commit

Permalink
ADM-513:[frontend] feat: fix the issue of review.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zxx-Ivy committed Dec 11, 2023
1 parent 8568da9 commit 91547d6
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion frontend/__tests__/src/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ export const MOCK_BUILD_KITE_VERIFY_RESPONSE = {
],
}

export const filterCycleTimeSettings = [
export const FILTER_CYCLE_TIME_SETTINGS = [
{ name: 'TODO', value: 'TODO' },
{ name: 'BACKLOG', value: 'TODO' },
{ name: 'IN DEV', value: 'IN DEV' },
Expand Down
4 changes: 2 additions & 2 deletions frontend/__tests__/src/utils/Util.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import { CleanedBuildKiteEmoji, OriginBuildKiteEmoji } from '@src/emojis/emoji'
import { EMPTY_STRING } from '@src/constants/commons'
import {
filterCycleTimeSettings,
FILTER_CYCLE_TIME_SETTINGS,
MOCK_CYCLE_TIME_SETTING,
MOCK_JIRA_WITH_STATUES_SETTING,
PIPELINE_TOOL_TYPES,
Expand Down Expand Up @@ -103,7 +103,7 @@ describe('findCaseInsensitiveType function', () => {
describe('filterAndMapCycleTimeSettings function', () => {
it('should filter and map CycleTimeSettings when generate report', () => {
const value = filterAndMapCycleTimeSettings(MOCK_CYCLE_TIME_SETTING, MOCK_JIRA_WITH_STATUES_SETTING)
expect(value).toStrictEqual(filterCycleTimeSettings)
expect(value).toStrictEqual(FILTER_CYCLE_TIME_SETTINGS)
})

it('should filter and map CycleTimeSettings when generate report', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '@src/components/Common/ReportForTwoColumns/style'
import React, { Fragment } from 'react'
import { ReportDataWithThreeColumns } from '@src/hooks/reportMapper/reportUIDataStructure'
import { AVERAGE_FIELD, Unit } from '@src/constants/resources'
import { AVERAGE_FIELD, REPORT_SUFFIX_UNITS } from '@src/constants/resources'
import { getEmojiUrls, removeExtraEmojiName } from '@src/emojis/emoji'
import { EmojiWrap, StyledAvatar, StyledTypography } from '@src/emojis/style'
import { ReportSelectionTitle } from '@src/components/Metrics/MetricsStep/style'
Expand Down Expand Up @@ -64,7 +64,10 @@ export const ReportForThreeColumns = ({ title, fieldName, listName, data }: Repo
<StyledTableCell>{fieldName}</StyledTableCell>
<StyledTableCell>{listName}</StyledTableCell>
<StyledTableCell>
Value{title === 'Lead time for changes' || title === 'Mean Time To Recovery' ? Unit.HOURS : ''}
Value
{title === 'Lead time for changes' || title === 'Mean Time To Recovery'
? REPORT_SUFFIX_UNITS.HOURS
: ''}
</StyledTableCell>
</TableRow>
</TableHead>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/constants/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export const NAME = 'Name'

export const AVERAGE_FIELD = 'Average'

export enum Unit {
export enum REPORT_SUFFIX_UNITS {
PER_SP = '(days/SP)',
PER_CARD = '(days/card)',
HOURS = '(hours)',
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/hooks/reportMapper/cycleTime.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CYCLE_TIME_METRICS_NAME, METRICS_CONSTANTS, Unit } from '@src/constants/resources'
import { CYCLE_TIME_METRICS_NAME, METRICS_CONSTANTS, REPORT_SUFFIX_UNITS } from '@src/constants/resources'
import { ReportDataWithTwoColumns, ValueWithUnits } from '@src/hooks/reportMapper/reportUIDataStructure'
import { CycleTimeResponse, Swimlane } from '@src/clients/report/dto/response'

Expand All @@ -21,21 +21,21 @@ export const cycleTimeMapper = ({
const swimlane = getSwimlaneByItemName(itemName)
return swimlane
? [
{ value: swimlane.averageTimeForSP.toFixed(2), unit: Unit.PER_SP },
{ value: swimlane.averageTimeForSP.toFixed(2), unit: REPORT_SUFFIX_UNITS.PER_SP },
{
value: swimlane.averageTimeForCards.toFixed(2),
unit: Unit.PER_CARD,
unit: REPORT_SUFFIX_UNITS.PER_CARD,
},
]
: []
}

const cycleTimeValue: { [key: string]: ValueWithUnits[] } = {
AVERAGE_CYCLE_TIME: [
{ value: Number(averageCycleTimePerSP.toFixed(2)), unit: Unit.PER_SP },
{ value: Number(averageCycleTimePerSP.toFixed(2)), unit: REPORT_SUFFIX_UNITS.PER_SP },
{
value: averageCycleTimePerCard.toFixed(2),
unit: Unit.PER_CARD,
unit: REPORT_SUFFIX_UNITS.PER_CARD,
},
],
DEVELOPMENT_PROPORTION: calPerColumnTotalTimeDivTotalTime(METRICS_CONSTANTS.inDevValue),
Expand Down

0 comments on commit 91547d6

Please sign in to comment.