Refactor: 쿼리 데이터 저장
This commit is contained in:
parent
fbf4c7a6a5
commit
56f63f59f2
@ -9,20 +9,32 @@ interface TrainingGraphProps {
|
||||
}
|
||||
|
||||
export default function TrainingGraph({ projectId, selectedModel }: TrainingGraphProps) {
|
||||
const { isTrainingByProject, setIsTraining, resetTrainingData } = useModelStore((state) => ({
|
||||
isTrainingByProject: state.isTrainingByProject,
|
||||
setIsTraining: state.setIsTraining,
|
||||
resetTrainingData: state.resetTrainingData,
|
||||
}));
|
||||
const { isTrainingByProject, setIsTraining, saveTrainingData, resetTrainingData, trainingDataByProject } =
|
||||
useModelStore((state) => ({
|
||||
isTrainingByProject: state.isTrainingByProject,
|
||||
setIsTraining: state.setIsTraining,
|
||||
saveTrainingData: state.saveTrainingData,
|
||||
resetTrainingData: state.resetTrainingData,
|
||||
trainingDataByProject: state.trainingDataByProject,
|
||||
}));
|
||||
|
||||
const isTraining = isTrainingByProject[projectId?.toString() || ''] || false;
|
||||
|
||||
const { data: trainingDataList } = usePollingModelReportsQuery(
|
||||
const { data: fetchedTrainingDataList } = usePollingModelReportsQuery(
|
||||
projectId as number,
|
||||
selectedModel ?? 0,
|
||||
isTraining && !!projectId && !!selectedModel
|
||||
);
|
||||
|
||||
const trainingDataList = useMemo(() => {
|
||||
return trainingDataByProject[projectId?.toString() || ''] || fetchedTrainingDataList || [];
|
||||
}, [projectId, trainingDataByProject, fetchedTrainingDataList]);
|
||||
useEffect(() => {
|
||||
if (fetchedTrainingDataList) {
|
||||
saveTrainingData(projectId?.toString() || '', fetchedTrainingDataList);
|
||||
}
|
||||
}, [fetchedTrainingDataList, projectId, saveTrainingData]);
|
||||
|
||||
const latestData = useMemo(() => {
|
||||
return (
|
||||
trainingDataList?.[trainingDataList.length - 1] || {
|
||||
|
Loading…
Reference in New Issue
Block a user