|
| 1 | +import { db } from '@sim/db' |
| 2 | +import { workflow, workflowExecutionLogs } from '@sim/db/schema' |
1 | 3 | import { createLogger } from '@sim/logger' |
2 | 4 | import { generateId } from '@sim/utils/id' |
| 5 | +import { eq } from 'drizzle-orm' |
3 | 6 | import { type NextRequest, NextResponse } from 'next/server' |
4 | 7 | import { v1GetLogContract } from '@/lib/api/contracts/v1/logs' |
5 | 8 | import { parseRequest } from '@/lib/api/server' |
6 | 9 | import { withRouteHandler } from '@/lib/core/utils/with-route-handler' |
7 | 10 | import { materializeExecutionDataForDisplay } from '@/lib/logs/execution/trace-store' |
8 | | -import { getPublicWorkflowLog } from '@/lib/logs/public-queries' |
9 | 11 | import { createApiResponse, getUserLimits } from '@/app/api/v1/logs/meta' |
10 | 12 | import { |
11 | 13 | checkRateLimit, |
@@ -36,7 +38,36 @@ export const GET = withRouteHandler( |
36 | 38 |
|
37 | 39 | const { id } = parsed.data.params |
38 | 40 |
|
39 | | - const log = await getPublicWorkflowLog({ column: 'id', value: id }) |
| 41 | + const rows = await db |
| 42 | + .select({ |
| 43 | + id: workflowExecutionLogs.id, |
| 44 | + workflowId: workflowExecutionLogs.workflowId, |
| 45 | + workspaceId: workflowExecutionLogs.workspaceId, |
| 46 | + executionId: workflowExecutionLogs.executionId, |
| 47 | + stateSnapshotId: workflowExecutionLogs.stateSnapshotId, |
| 48 | + level: workflowExecutionLogs.level, |
| 49 | + trigger: workflowExecutionLogs.trigger, |
| 50 | + startedAt: workflowExecutionLogs.startedAt, |
| 51 | + endedAt: workflowExecutionLogs.endedAt, |
| 52 | + totalDurationMs: workflowExecutionLogs.totalDurationMs, |
| 53 | + executionData: workflowExecutionLogs.executionData, |
| 54 | + costTotal: workflowExecutionLogs.costTotal, |
| 55 | + files: workflowExecutionLogs.files, |
| 56 | + createdAt: workflowExecutionLogs.createdAt, |
| 57 | + workflowName: workflow.name, |
| 58 | + workflowDescription: workflow.description, |
| 59 | + workflowFolderId: workflow.folderId, |
| 60 | + workflowUserId: workflow.userId, |
| 61 | + workflowWorkspaceId: workflow.workspaceId, |
| 62 | + workflowCreatedAt: workflow.createdAt, |
| 63 | + workflowUpdatedAt: workflow.updatedAt, |
| 64 | + }) |
| 65 | + .from(workflowExecutionLogs) |
| 66 | + .leftJoin(workflow, eq(workflowExecutionLogs.workflowId, workflow.id)) |
| 67 | + .where(eq(workflowExecutionLogs.id, id)) |
| 68 | + .limit(1) |
| 69 | + |
| 70 | + const log = rows[0] |
40 | 71 | if (!log) { |
41 | 72 | return NextResponse.json({ error: 'Log not found' }, { status: 404 }) |
42 | 73 | } |
|
0 commit comments