@@ -130,6 +130,8 @@ export async function GET(request: NextRequest) {
130130 deploymentVersionName : sql < null > `NULL` ,
131131 }
132132
133+ const workspaceFilter = eq ( workflowExecutionLogs . workspaceId , params . workspaceId )
134+
133135 const baseQuery = db
134136 . select ( selectColumns )
135137 . from ( workflowExecutionLogs )
@@ -141,18 +143,12 @@ export async function GET(request: NextRequest) {
141143 workflowDeploymentVersion ,
142144 eq ( workflowDeploymentVersion . id , workflowExecutionLogs . deploymentVersionId )
143145 )
144- . innerJoin (
145- workflow ,
146- and (
147- eq ( workflowExecutionLogs . workflowId , workflow . id ) ,
148- eq ( workflow . workspaceId , params . workspaceId )
149- )
150- )
146+ . innerJoin ( workflow , eq ( workflowExecutionLogs . workflowId , workflow . id ) )
151147 . innerJoin (
152148 permissions ,
153149 and (
154150 eq ( permissions . entityType , 'workspace' ) ,
155- eq ( permissions . entityId , workflow . workspaceId ) ,
151+ eq ( permissions . entityId , workflowExecutionLogs . workspaceId ) ,
156152 eq ( permissions . userId , userId )
157153 )
158154 )
@@ -300,7 +296,7 @@ export async function GET(request: NextRequest) {
300296 }
301297
302298 const logs = await baseQuery
303- . where ( conditions )
299+ . where ( and ( workspaceFilter , conditions ) )
304300 . orderBy ( desc ( workflowExecutionLogs . startedAt ) )
305301 . limit ( params . limit )
306302 . offset ( params . offset )
@@ -312,22 +308,16 @@ export async function GET(request: NextRequest) {
312308 pausedExecutions ,
313309 eq ( pausedExecutions . executionId , workflowExecutionLogs . executionId )
314310 )
315- . innerJoin (
316- workflow ,
317- and (
318- eq ( workflowExecutionLogs . workflowId , workflow . id ) ,
319- eq ( workflow . workspaceId , params . workspaceId )
320- )
321- )
311+ . innerJoin ( workflow , eq ( workflowExecutionLogs . workflowId , workflow . id ) )
322312 . innerJoin (
323313 permissions ,
324314 and (
325315 eq ( permissions . entityType , 'workspace' ) ,
326- eq ( permissions . entityId , workflow . workspaceId ) ,
316+ eq ( permissions . entityId , workflowExecutionLogs . workspaceId ) ,
327317 eq ( permissions . userId , userId )
328318 )
329319 )
330- . where ( conditions )
320+ . where ( and ( eq ( workflowExecutionLogs . workspaceId , params . workspaceId ) , conditions ) )
331321
332322 const countResult = await countQuery
333323
0 commit comments