fix: update workflow run with workflow id
This commit is contained in:
@@ -39,16 +39,8 @@ export async function findFirstTableWithVersion(workflow_id: string) {
|
||||
}
|
||||
|
||||
export async function findAllRuns(workflow_id: string) {
|
||||
const workflowVersion = await db.query.workflowVersionTable.findFirst({
|
||||
where: eq(workflowVersionTable.workflow_id, workflow_id),
|
||||
});
|
||||
|
||||
if (!workflowVersion) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return await db.query.workflowRunsTable.findMany({
|
||||
where: eq(workflowRunsTable.workflow_version_id, workflowVersion?.id),
|
||||
where: eq(workflowRunsTable.workflow_id, workflow_id),
|
||||
orderBy: desc(workflowRunsTable.created_at),
|
||||
with: {
|
||||
machine: {
|
||||
@@ -77,7 +69,7 @@ export default async function Page({
|
||||
|
||||
return (
|
||||
<div className="mt-4 w-full flex flex-col lg:flex-row gap-4">
|
||||
<Card className="w-full lg:w-fit lg:min-w-[500px]">
|
||||
<Card className="w-full lg:w-fit lg:min-w-[500px] h-fit">
|
||||
<CardHeader>
|
||||
<CardTitle>{workflow?.name}</CardTitle>
|
||||
<CardDescription suppressHydrationWarning={true}>
|
||||
|
||||
@@ -78,6 +78,8 @@ export async function POST(request: Request) {
|
||||
});
|
||||
});
|
||||
|
||||
console.log(result);
|
||||
|
||||
// return the error
|
||||
if (result instanceof Response) {
|
||||
return result;
|
||||
@@ -88,6 +90,7 @@ export async function POST(request: Request) {
|
||||
.insert(workflowRunsTable)
|
||||
.values({
|
||||
id: result.prompt_id,
|
||||
workflow_id: workflow_version_data.workflow_id,
|
||||
workflow_version_id: workflow_version_data.id,
|
||||
machine_id,
|
||||
})
|
||||
|
||||
@@ -75,6 +75,11 @@ export const workflowRunsTable = dbSchema.table("workflow_runs", {
|
||||
.references(() => workflowVersionTable.id, {
|
||||
onDelete: "no action",
|
||||
}),
|
||||
workflow_id: uuid("workflow_id")
|
||||
.notNull()
|
||||
.references(() => workflowTable.id, {
|
||||
onDelete: "no action",
|
||||
}),
|
||||
machine_id: uuid("machine_id")
|
||||
.notNull()
|
||||
.references(() => machinesTable.id, {
|
||||
|
||||
Reference in New Issue
Block a user