diff --git a/src/store.ts b/src/store.ts index 19663c5..e25467c 100644 --- a/src/store.ts +++ b/src/store.ts @@ -1112,31 +1112,69 @@ export async function loadPipelineStats(fileUuid: string, force = false): Promis const stages = data.stages || [] - const WEIGHT_MAP: Record = { - processors: 0.30, - rule1_ingestion: 0.05, - face_tracing: 0.05, - face_dedup: 0.10, - tkg_nodes: 0.20, - tkg_edges: 0.15, - rule2_ingestion: 0.10, - vlm_summary: 0.03, - scene_vlm: 0.03, - moment_chunks: 0.01 + // Map individual steps to phases + const phaseMap: Record = { + processors: { + weight: 0.30, + steps: ['processors'] + }, + knowledge_graph: { + weight: 0.35, + steps: ['tkg_nodes', 'tkg_edges'] + }, + moment_extraction: { + weight: 0.06, + steps: ['vlm_summary', 'scene_vlm', 'moment_chunks'] + }, + integration: { + weight: 0.29, + steps: ['rule1_ingestion', 'rule2_ingestion', 'face_tracing', 'face_dedup'] + } } - const mappedStages = stages.map((s: any) => ({ - name: s.name, - weight: WEIGHT_MAP[s.name] ?? s.weight ?? 0, - progress: s.progress || 0, - status: s.status || 'pending' - })) + // Aggregate steps into phases + const aggregatedStages: PipelineStage[] = [] - const calculatedProgress = mappedStages.reduce((sum, s) => sum + s.weight * s.progress, 0) + for (const [phaseName, phaseConfig] of Object.entries(phaseMap)) { + const phaseSteps = stages.filter((s: any) => phaseConfig.steps.includes(s.name)) + + if (phaseSteps.length > 0) { + // Calculate phase progress from steps + const totalWeight = phaseSteps.reduce((sum: number, s: any) => sum + (s.weight || 0), 0) + const weightedProgress = phaseSteps.reduce((sum: number, s: any) => { + const stepWeight = s.weight || 0 + return sum + stepWeight * (s.progress || 0) + }, 0) + + const phaseProgress = totalWeight > 0 ? weightedProgress / totalWeight : 0 + + // Determine phase status + const allCompleted = phaseSteps.every((s: any) => s.status === 'completed') + const anyRunning = phaseSteps.some((s: any) => s.status === 'running') + const anyFailed = phaseSteps.some((s: any) => s.status === 'failed') + + let phaseStatus: 'pending' | 'running' | 'completed' | 'failed' = 'pending' + if (anyFailed) phaseStatus = 'failed' + else if (allCompleted) phaseStatus = 'completed' + else if (anyRunning) phaseStatus = 'running' + + aggregatedStages.push({ + name: phaseName, + weight: phaseConfig.weight, + progress: phaseProgress, + status: phaseStatus + }) + } + } + + const calculatedProgress = aggregatedStages.reduce((sum, s) => sum + s.weight * s.progress, 0) const pipelineStats: PipelineStats = { overall_progress: calculatedProgress, - stages: mappedStages + stages: aggregatedStages } console.log('[loadPipelineStats]', fileUuid, pipelineStats) diff --git a/src/views/LibraryView.vue b/src/views/LibraryView.vue index cf9b51f..7c50135 100644 --- a/src/views/LibraryView.vue +++ b/src/views/LibraryView.vue @@ -1179,6 +1179,10 @@ function getStageIcon(status: string): string { function formatStageName(name: string): string { const names: Record = { processors: 'Processors', + knowledge_graph: 'Knowledge Graph', + moment_extraction: 'Moment Extraction', + integration: 'Integration', + // Keep old names for backward compatibility rule1_ingestion: 'Rule1 Ingestion', face_tracing: 'Face Tracing', face_dedup: 'Face Dedup',