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

fix: project report detail time range optimization #3937

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
18 changes: 12 additions & 6 deletions shell/app/modules/dop/pages/report/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import RateSelect from './rate-select';
import ChartColumn from './chart-column';

interface listItem extends Report {
chart: Report[];
chart?: Report[];
}

const cardColorList = [undefined, '#16c2c3', '#697fff', '#f3b519'];
Expand All @@ -37,7 +37,7 @@ const ProjectReport = ({ route }: { route: { path: string } }) => {
const orgId = orgStore.useStore((s) => s.currentOrg.id);
const [data, setData] = useState<Report[]>([]);
const [visible, setVisible] = useState(false);
const [detailData, setDetailData] = useState<Report>({} as Report);
const [detailData, setDetailData] = useState<listItem>({} as listItem);
const [loading, setLoading] = useState(false);
const [filterData, setFilterData] = useState<Obj>({
time: [moment().subtract(7, 'day').startOf('day').valueOf(), moment().endOf('day').valueOf()],
Expand Down Expand Up @@ -97,6 +97,7 @@ const ProjectReport = ({ route }: { route: { path: string } }) => {
if (detailData?.projectID && visible) {
getIterations(detailData.projectID);
getState();
getDatail([]);
}
}, [detailData.projectID, visible]);

Expand All @@ -111,12 +112,17 @@ const ProjectReport = ({ route }: { route: { path: string } }) => {

const getDatail = async (iterationIDs: number[]) => {
setDetailLoading(true);
const { time } = filterData;
const { projectID } = detailData;
const { projectID, beginDate, endDate, chart } = detailData;
const end = endDate || moment().format('YYYY-MM-DD HH:mm:ss');
const start =
beginDate ||
chart?.find((item) => item.beginDate)?.beginDate ||
moment(end).subtract(1, 'months').format('YYYY-MM-DD HH:mm:ss');

const payload = {
orgId,
start: moment(time[0]).format('YYYY-MM-DD HH:mm:ss'),
end: moment(time[1]).format('YYYY-MM-DD HH:mm:ss'),
start,
end,
projectIDs: [Number(projectID)],
iterationIDs,
};
Expand Down
Loading