11import { z } from "zod" ;
22
3- import { and , desc , eq , isNull } from "@ctrlplane/db" ;
3+ import { and , desc , eq , isNull , like } from "@ctrlplane/db" ;
44import * as schema from "@ctrlplane/db/schema" ;
55import { Permission } from "@ctrlplane/validators/auth" ;
66
@@ -233,6 +233,7 @@ export const deploymentTracesRouter = router({
233233 workspaceId : z . string ( ) . uuid ( ) ,
234234 limit : z . number ( ) . min ( 1 ) . max ( 1000 ) . default ( 100 ) ,
235235 offset : z . number ( ) . min ( 0 ) . default ( 0 ) ,
236+ deploymentId : z . string ( ) . uuid ( ) . optional ( ) ,
236237 releaseId : z . string ( ) . optional ( ) ,
237238 releaseTargetKey : z . string ( ) . optional ( ) ,
238239 jobId : z . string ( ) . optional ( ) ,
@@ -251,6 +252,16 @@ export const deploymentTracesRouter = router({
251252 isNull ( schema . deploymentTraceSpan . parentSpanId ) ,
252253 ] ;
253254
255+ // Filter by deploymentId - releaseTargetKey format is "resourceId-environmentId-deploymentId"
256+ if ( input . deploymentId ) {
257+ conditions . push (
258+ like (
259+ schema . deploymentTraceSpan . releaseTargetKey ,
260+ `%-${ input . deploymentId } ` ,
261+ ) ,
262+ ) ;
263+ }
264+
254265 if ( input . releaseId ) {
255266 conditions . push (
256267 eq ( schema . deploymentTraceSpan . releaseId , input . releaseId ) ,
0 commit comments