Major fixes: - Fix pivot transformation with special characters in column names - Fix compute column validation for Chinese punctuation - Fix recode dialog to fetch unique values from full dataset via new API - Add column mapping mechanism to handle special characters Database migration: - Add column_mapping field to dc_tool_c_sessions table - Migration file: 20251208_add_column_mapping UX improvements: - Darken table grid lines for better visibility - Reduce column width by 40% with tooltip support - Insert new columns next to source columns - Preserve original row order after operations - Add notice about 50-row preview limit Modified files: - Backend: SessionService, SessionController, QuickActionService, routes - Python: pivot.py, compute.py, recode.py, binning.py, conditional.py - Frontend: DataGrid, RecodeDialog, index.tsx, ag-grid-custom.css - Database: schema.prisma, migration SQL Status: Code complete, database migrated, ready for testing
82 lines
1.5 KiB
TypeScript
82 lines
1.5 KiB
TypeScript
/**
|
||
* 全文复筛任务进度Hook
|
||
*
|
||
* 功能:
|
||
* 1. 轮询任务进度
|
||
* 2. 自动刷新
|
||
* 3. 错误处理
|
||
*/
|
||
|
||
import { useQuery } from '@tanstack/react-query';
|
||
import { aslApi } from '../api';
|
||
|
||
interface UseFulltextTaskOptions {
|
||
taskId: string;
|
||
enabled?: boolean;
|
||
refetchInterval?: number | false;
|
||
}
|
||
|
||
export function useFulltextTask({
|
||
taskId,
|
||
enabled = true,
|
||
refetchInterval,
|
||
}: UseFulltextTaskOptions) {
|
||
const {
|
||
data,
|
||
isLoading,
|
||
error,
|
||
refetch,
|
||
} = useQuery({
|
||
queryKey: ['fulltextTask', taskId],
|
||
queryFn: async () => {
|
||
const response = await aslApi.getFulltextTaskProgress(taskId);
|
||
return response.data;
|
||
},
|
||
enabled: enabled && !!taskId,
|
||
refetchInterval: refetchInterval !== undefined
|
||
? refetchInterval
|
||
: ((data) => {
|
||
// 默认行为:任务进行中时每2秒轮询,否则停止
|
||
if (!data?.data) return false;
|
||
const status = (data.data as any).status;
|
||
return status === 'processing' || status === 'pending' ? 2000 : false;
|
||
}),
|
||
retry: 1,
|
||
});
|
||
|
||
const task = data as any;
|
||
const isRunning = task?.status === 'processing' || task?.status === 'pending';
|
||
const isCompleted = task?.status === 'completed';
|
||
const isFailed = task?.status === 'failed';
|
||
const progress = task?.progress?.progressPercent || 0;
|
||
|
||
return {
|
||
task,
|
||
progress,
|
||
isRunning,
|
||
isCompleted,
|
||
isFailed,
|
||
isLoading,
|
||
error,
|
||
refetch,
|
||
};
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|