Skip to content

Commit

Permalink
ADM-952 [frontend][backend] adjust according to DC (#1494)
Browse files Browse the repository at this point in the history
* ADM-952 [frontend]: change README and style

* ADM-952 [backend]: change vietnam national holiday logic

* ADM-952 [backend]: format

* ADM-952 [backend]: remove useless code
  • Loading branch information
Mandy-Tang authored Jun 20, 2024
1 parent 5751e06 commit 41e7fcd
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 45 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,11 @@ Users need to select at least one period of time, and users can click the “New

Note: Charts will be generated only by selecting at least 2 time periods.

**Have two items of time period:**
**Have three items of time period:**

1. **Regular Calendar(Weekend Considered):** If you select this item, it means all data will exclude the weekend.
1. **Regular Calendar:** If you select this item, it means all data will exclude the weekend.
2. **Calendar with Chinese Holiday:** If you select this item, it means all data will exclude the weekend and Chinese holiday. So if the time period you selected contains Chinese holiday, you need to select this item.
3. **Calendar with Vietnam Holiday:** If you select this item, it means all data will exclude the weekend and Vietnam holiday. So if the time period you selected contains Vietnam holiday, you need to select this item.

All need to select which data you want to get, for now, we support seven metrics data (Image 3-3). Those seven metrics are `Deployment Frequency (DF)`, `Lead Time for changes (LTC)`, `Mean Time To Recover (MTTR)`, `Change Failure Rate (CFR)`, and `Velocity`, `Cycle time`, `Classification`, where

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ public Map<String, Boolean> loadHolidayList(String year) {

holidays.forEach(holiday -> {
String date = holiday.getDate().getIso();
holidayMap.put(date, holiday.getType().contains("National holiday"));
if (holiday.getType().contains("National holiday")) {
holidayMap.put(date, true);
}
});
return holidayMap;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@
import org.mockito.quality.Strictness;

import java.util.Map;
import java.util.Objects;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
Expand Down Expand Up @@ -54,15 +51,7 @@ void loadHolidayListSuccess() throws Exception {

Map<String, Boolean> result = vietnamHoliday.loadHolidayList(year);

assertEquals(6, result.size());
for (String key : result.keySet()) {
if (Objects.equals(key, "2024-01-01")) {
assertTrue(result.get(key));
}
else {
assertFalse(result.get(key));
}
}
assertEquals(Map.of("2024-01-01", true), result);
verify(calendarificFeignClient).getHolidays(country.getValue().toLowerCase(), year);
verify(objectMapper).readValue(eq(calendarificHolidayResponseDTOString), any(Class.class));
}
Expand Down
56 changes: 29 additions & 27 deletions frontend/src/containers/ConfigStep/BasicInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { ConfigSectionContainer } from '@src/components/Common/ConfigForms';
import { useAppDispatch, useAppSelector } from '@src/hooks/useAppDispatch';
import { ConfigSelectionTitle } from '@src/containers/MetricsStep/style';
import { CALENDAR_LABEL, CALENDAR_LIST } from '@src/constants/resources';
import { FormControl, Radio, RadioGroup } from '@mui/material';
import { Controller, useFormContext } from 'react-hook-form';
import { Radio, RadioGroup } from '@mui/material';

const BasicInfo = () => {
const dispatch = useAppDispatch();
Expand Down Expand Up @@ -45,32 +45,34 @@ const BasicInfo = () => {
)}
/>

<CollectionDateLabel>Collection Date(Weekend Considered)</CollectionDateLabel>
<Controller
name={'calendarType'}
control={control}
render={({ field }) => {
return (
<RadioGroup
{...field}
onChange={(e) => {
field.onChange(e.target.value);
dispatch(updateCalendarType(e.target.value));
}}
>
{CALENDAR_LIST.map((calendarType) => (
<StyledFormControlLabel
key={calendarType}
value={calendarType}
control={<Radio />}
name={CALENDAR_LABEL[calendarType]}
label={CALENDAR_LABEL[calendarType]}
/>
))}
</RadioGroup>
);
}}
/>
<FormControl required>
<CollectionDateLabel>Collection Date (Weekend Considered)</CollectionDateLabel>
<Controller
name={'calendarType'}
control={control}
render={({ field }) => {
return (
<RadioGroup
{...field}
onChange={(e) => {
field.onChange(e.target.value);
dispatch(updateCalendarType(e.target.value));
}}
>
{CALENDAR_LIST.map((calendarType) => (
<StyledFormControlLabel
key={calendarType}
value={calendarType}
control={<Radio />}
name={CALENDAR_LABEL[calendarType]}
label={CALENDAR_LABEL[calendarType]}
/>
))}
</RadioGroup>
);
}}
/>
</FormControl>
<DateRangePickerSection />
<RequiredMetrics />
</ConfigSectionContainer>
Expand Down
7 changes: 4 additions & 3 deletions frontend/src/containers/ConfigStep/BasicInfo/style.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FormControlLabel, TextField } from '@mui/material';
import { FormControlLabel, FormLabel, TextField } from '@mui/material';
import { css, styled } from '@mui/material/styles';
import { theme } from '@src/theme';

Expand All @@ -16,10 +16,11 @@ export const StyledFormControlLabel = styled(FormControlLabel)`
`}
`;

export const CollectionDateLabel = styled('div')({
export const CollectionDateLabel = styled(FormLabel)({
width: '100%',
color: theme.palette.secondary.contrastText,
fontSize: '0.8rem',
fontSize: '0.75rem',
lineHeight: '2em',
boxSizing: 'border-box',
marginTop: '1rem',
});

0 comments on commit 41e7fcd

Please sign in to comment.