import { useSmithers } from "smithers-orchestrator";
import { useQueryValue } from "smithers-orchestrator/reactive-sqlite";
function useWorkflowProgress() {
const { reactiveDb, executionId } = useSmithers();
const { data: total } = useQueryValue<number>(
reactiveDb,
"SELECT COUNT(*) as count FROM phases WHERE execution_id = ?",
[executionId ?? ""],
{ skip: !executionId }
);
const { data: completed } = useQueryValue<number>(
reactiveDb,
"SELECT COUNT(*) as count FROM phases WHERE execution_id = ? AND status = 'completed'",
[executionId ?? ""],
{ skip: !executionId }
);
const progress = total ? (completed ?? 0) / total : 0;
return { progress, total: total ?? 0, completed: completed ?? 0 };
}