Refactor pipeline task handling and UI flows
This commit is contained in:
@@ -350,6 +350,7 @@ export const queueLeadAuditGeneration = internalMutation({
|
||||
leadId: v.id("leads"),
|
||||
auditId: v.optional(v.id("audits")),
|
||||
parentRunId: v.optional(v.id("agentRuns")),
|
||||
scheduleAction: v.optional(v.boolean()),
|
||||
},
|
||||
returns: v.union(v.id("agentRuns"), v.null()),
|
||||
handler: async (ctx, args): Promise<Id<"agentRuns"> | null> => {
|
||||
@@ -418,13 +419,15 @@ export const queueLeadAuditGeneration = internalMutation({
|
||||
createdAt: now,
|
||||
});
|
||||
|
||||
await ctx.scheduler.runAfter(
|
||||
0,
|
||||
internal.auditGenerationAction.processAuditGeneration,
|
||||
{
|
||||
runId,
|
||||
},
|
||||
);
|
||||
if (args.scheduleAction !== false) {
|
||||
await ctx.scheduler.runAfter(
|
||||
0,
|
||||
internal.auditGenerationAction.processAuditGeneration,
|
||||
{
|
||||
runId,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
return runId;
|
||||
},
|
||||
@@ -460,7 +463,11 @@ export const startAuditGenerationRun = internalMutation({
|
||||
const now = Date.now();
|
||||
const run = await ctx.db.get(args.runId);
|
||||
|
||||
if (!run || run.type !== "audit_generation" || run.status !== "pending") {
|
||||
if (
|
||||
!run ||
|
||||
run.type !== "audit_generation" ||
|
||||
(run.status !== "pending" && run.status !== "failed")
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -511,6 +518,7 @@ export const startAuditGenerationRun = internalMutation({
|
||||
status: "running",
|
||||
currentStep: "audit_generation",
|
||||
startedAt: now,
|
||||
finishedAt: undefined,
|
||||
updatedAt: now,
|
||||
errorSummary: undefined,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user