From 9e206fb92b98110170d6c06e49d2445df53b1a82 Mon Sep 17 00:00:00 2001 From: Vishesh 'ironeagle' Bangotra Date: Sat, 30 May 2026 03:43:15 +0530 Subject: [PATCH] enrich and save sse --- src/FetchRequestDetail.tsx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/FetchRequestDetail.tsx b/src/FetchRequestDetail.tsx index 8f370b1..13900a1 100644 --- a/src/FetchRequestDetail.tsx +++ b/src/FetchRequestDetail.tsx @@ -66,11 +66,11 @@ function computeProgressPercent( if (status === "pending") return 0; if (status === "completed") return 100; - if (seenSteps.has("complete")) return 90; + if (seenSteps.has("save_expenses") || seenSteps.has("complete")) return 95; if (seenSteps.has("enrich")) return 85; if (seenSteps.has("txn_dicts/completed")) return 80; - if (seenSteps.has("txn_dicts/started") && liveCount > 0) { + if (seenSteps.has("txn_dicts") && liveCount > 0) { return Math.min(80, 35 + Math.min(liveCount, 300) / 300 * 45); } @@ -85,7 +85,7 @@ const stepLabels = ["Load Content", "Extract", "Raw Expense", "Enrich", "Save"]; function computeActiveStep(status: FetchRequestStatus, seenSteps: Set): number { if (status === "completed") return stepLabels.length; - if (seenSteps.has("complete")) return 4; + if (seenSteps.has("save_expenses") || seenSteps.has("complete")) return 4; if (seenSteps.has("enrich") || status === "enriched_done") return 3; if (seenSteps.has("txn_dicts") || status === "raw_expenses_done") return 2; if (seenSteps.has("txn_blocks")) return 1; @@ -155,9 +155,12 @@ export default function FetchRequestDetail() { const dictCount = stepStats.txn_dicts ?? liveParsedCount ?? 0; if (dictCount) msgs[2] = `${dictCount} dicts`; - if (["enriched_done", "completed"].includes((fetchRequest as any)?.status)) + if (stepStats.enrich_count) msgs[3] = `${stepStats.enrich_count} enriched`; + else if (["enriched_done", "completed"].includes((fetchRequest as any)?.status)) msgs[3] = "done"; - if ((fetchRequest as any)?.status === "completed") + + if (stepStats.save_count) msgs[4] = `${stepStats.save_count} saved`; + else if ((fetchRequest as any)?.status === "completed") msgs[4] = (fetchRequest as any)?.completed_at ? new Date((fetchRequest as any).completed_at).toLocaleString() : "done"; @@ -181,11 +184,13 @@ export default function FetchRequestDetail() { setLiveParsedCount(parsed.message.count); } - if (parsed.status === "completed") { + if (parsed.status === "completed" && parsed.message.count !== undefined) { const stats: Record = {}; if (parsed.step === "raw_lines" && parsed.message.lines !== undefined) stats.raw_lines = parsed.message.lines; if (parsed.step === "txn_blocks" && parsed.message.blocks !== undefined) stats.txn_blocks = parsed.message.blocks; - if (parsed.step === "txn_dicts" && parsed.message.count !== undefined) stats.txn_dicts = parsed.message.count; + if (parsed.step === "txn_dicts") stats.txn_dicts = parsed.message.count; + if (parsed.step === "enrich") stats.enrich_count = parsed.message.count; + if (parsed.step === "save_expenses") stats.save_count = parsed.message.count; if (Object.keys(stats).length) { setStepStats((prev) => ({ ...prev, ...stats })); }