({
userId,
workspaceId,
lookupColumn,
lookupValue,
}: FetchLogDetailArgs)
| 89 | * boundary. |
| 90 | */ |
| 91 | export 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 | ? { |
no test coverage detected