Skip to content

Commit e956dd2

Browse files
committed
feat: add deploymentId filter to deployment traces query and update schema validation
1 parent 37f74ec commit e956dd2

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

apps/web/app/routes/ws/deployments/page.$deploymentId.traces.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ export default function DeploymentTraces() {
165165
const tracesQuery = trpc.deploymentTraces.getUniqueTraces.useQuery(
166166
{
167167
workspaceId: workspace.id,
168+
deploymentId: deployment.id,
168169
limit: 100,
169170
offset: 0,
170171
releaseId: filters.releaseId ?? undefined,

packages/trpc/src/routes/deployment-traces.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { z } from "zod";
22

3-
import { and, desc, eq, isNull } from "@ctrlplane/db";
3+
import { and, desc, eq, isNull, like } from "@ctrlplane/db";
44
import * as schema from "@ctrlplane/db/schema";
55
import { 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

Comments
 (0)