Skip to content

Commit

Permalink
fix: Error on chat api,<BadRequestKeyError '400: Bad Request'> infini…
Browse files Browse the repository at this point in the history
  • Loading branch information
cike8899 committed Aug 13, 2024
1 parent eb8feaf commit 03e8659
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ const ChatOverviewModal = ({
value={pickerValue}
onChange={setPickerValue}
allowClear={false}
// onPanelChange={setPickerValue}
/>
</Space>
<div className={styles.chartWrapper}>
Expand Down
8 changes: 6 additions & 2 deletions web/src/components/api-service/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
useCreateNextToken,
useFetchNextStats,
useFetchTokenList,
useRemoveNextToken,
} from '@/hooks/chat-hooks';
Expand All @@ -10,6 +9,7 @@ import {
useTranslate,
} from '@/hooks/common-hooks';
import { IStats } from '@/interfaces/database/chat';
import { useQueryClient } from '@tanstack/react-query';
import { message } from 'antd';
import { useCallback } from 'react';

Expand Down Expand Up @@ -46,7 +46,11 @@ type ChartStatsType = {
};

export const useSelectChartStatsList = (): ChartStatsType => {
const { data: stats } = useFetchNextStats();
const queryClient = useQueryClient();
const data = queryClient.getQueriesData({ queryKey: ['fetchStats'] });
console.log('🚀 ~ useSelectChartStatsList ~ data:', data);
// const { data: stats } = useFetchNextStats();
const stats = data[0][1];

return Object.keys(stats).reduce((pre, cur) => {
const item = stats[cur as keyof IStats];
Expand Down
2 changes: 1 addition & 1 deletion web/src/hooks/chat-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ const getDay = (date?: Dayjs) => date?.format('YYYY-MM-DD');

export const useFetchNextStats = () => {
const [pickerValue, setPickerValue] = useState<RangeValue>([
dayjs(),
dayjs().subtract(7, 'day'),
dayjs(),
]);
const { data, isFetching: loading } = useQuery<IStats>({
queryKey: ['fetchStats', pickerValue],
Expand Down

0 comments on commit 03e8659

Please sign in to comment.