MCPcopy Index your code
hub / github.com/simstudioai/sim / fetchLogDetail

Function fetchLogDetail

apps/sim/lib/logs/fetch-log-detail.ts:91–276  ·  view source on GitHub ↗
({
  userId,
  workspaceId,
  lookupColumn,
  lookupValue,
}: FetchLogDetailArgs)

Source from the content-addressed store, hash-verified

89 * boundary.
90 */
91export async function fetchLogDetail({
92 userId,
93 workspaceId,
94 lookupColumn,
95 lookupValue,
96}: FetchLogDetailArgs) {
97 const access = await checkWorkspaceAccess(workspaceId, userId)
98 if (!access.hasAccess) return null
99
100 const workflowMatch: SQL =
101 lookupColumn === 'id'
102 ? eq(workflowExecutionLogs.id, lookupValue)
103 : eq(workflowExecutionLogs.executionId, lookupValue)
104
105 const rows = await db
106 .select({
107 id: workflowExecutionLogs.id,
108 workflowId: workflowExecutionLogs.workflowId,
109 executionId: workflowExecutionLogs.executionId,
110 deploymentVersionId: workflowExecutionLogs.deploymentVersionId,
111 level: workflowExecutionLogs.level,
112 status: workflowExecutionLogs.status,
113 trigger: workflowExecutionLogs.trigger,
114 startedAt: workflowExecutionLogs.startedAt,
115 endedAt: workflowExecutionLogs.endedAt,
116 totalDurationMs: workflowExecutionLogs.totalDurationMs,
117 executionData: workflowExecutionLogs.executionData,
118 costTotal: workflowExecutionLogs.costTotal,
119 files: workflowExecutionLogs.files,
120 createdAt: workflowExecutionLogs.createdAt,
121 workflowName: workflow.name,
122 workflowDescription: workflow.description,
123 workflowFolderId: workflow.folderId,
124 workflowUserId: workflow.userId,
125 workflowWorkspaceId: workflow.workspaceId,
126 workflowCreatedAt: workflow.createdAt,
127 workflowUpdatedAt: workflow.updatedAt,
128 deploymentVersion: workflowDeploymentVersion.version,
129 deploymentVersionName: workflowDeploymentVersion.name,
130 pausedStatus: pausedExecutions.status,
131 pausedTotalPauseCount: pausedExecutions.totalPauseCount,
132 pausedResumedCount: pausedExecutions.resumedCount,
133 })
134 .from(workflowExecutionLogs)
135 .leftJoin(workflow, eq(workflowExecutionLogs.workflowId, workflow.id))
136 .leftJoin(
137 workflowDeploymentVersion,
138 eq(workflowDeploymentVersion.id, workflowExecutionLogs.deploymentVersionId)
139 )
140 .leftJoin(pausedExecutions, eq(pausedExecutions.executionId, workflowExecutionLogs.executionId))
141 .where(and(workflowMatch, eq(workflowExecutionLogs.workspaceId, workspaceId)))
142 .limit(1)
143
144 const log = rows[0]
145
146 if (log) {
147 const workflowSummary = log.workflowId
148 ? {

Callers 3

executeFunction · 0.90
route.tsFile · 0.90
route.tsFile · 0.90

Calls 8

checkWorkspaceAccessFunction · 0.90
materializeExecutionDataFunction · 0.90
getProgressMarkersFunction · 0.90
pickLatestStartedMarkerFunction · 0.90
buildCostLedgerFunction · 0.85
jobCostTotalFunction · 0.85
eqFunction · 0.50

Tested by

no test coverage detected