Skip to content

Commit 766526b

Browse files
fix(logs): restore narrow v1 detail query (#6588)
1 parent 083319b commit 766526b

1 file changed

Lines changed: 33 additions & 2 deletions

File tree

apps/sim/app/api/v1/logs/[id]/route.ts

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
import { db } from '@sim/db'
2+
import { workflow, workflowExecutionLogs } from '@sim/db/schema'
13
import { createLogger } from '@sim/logger'
24
import { generateId } from '@sim/utils/id'
5+
import { eq } from 'drizzle-orm'
36
import { type NextRequest, NextResponse } from 'next/server'
47
import { v1GetLogContract } from '@/lib/api/contracts/v1/logs'
58
import { parseRequest } from '@/lib/api/server'
69
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
710
import { materializeExecutionDataForDisplay } from '@/lib/logs/execution/trace-store'
8-
import { getPublicWorkflowLog } from '@/lib/logs/public-queries'
911
import { createApiResponse, getUserLimits } from '@/app/api/v1/logs/meta'
1012
import {
1113
checkRateLimit,
@@ -36,7 +38,36 @@ export const GET = withRouteHandler(
3638

3739
const { id } = parsed.data.params
3840

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]
4071
if (!log) {
4172
return NextResponse.json({ error: 'Log not found' }, { status: 404 })
4273
}

0 commit comments

Comments
 (0)