Skip to content

Commit

Permalink
fix: On approve only dispatch pending
Browse files Browse the repository at this point in the history
  • Loading branch information
adityachoudhari26 committed Oct 19, 2024
1 parent 63c40a3 commit 6104a79
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/api/src/router/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
environmentPolicyApproval,
environmentPolicyDeployment,
environmentPolicyReleaseWindow,
job,
release,
releaseJobTrigger,
setPolicyReleaseWindow,
Expand All @@ -38,6 +39,7 @@ import {
isPassingAllPolicies,
} from "@ctrlplane/job-dispatch";
import { Permission } from "@ctrlplane/validators/auth";
import { JobStatus } from "@ctrlplane/validators/jobs";

import { createTRPCRouter, protectedProcedure } from "../trpc";

Expand Down Expand Up @@ -183,12 +185,14 @@ const policyRouter = createTRPCRouter({
releaseJobTrigger,
eq(releaseJobTrigger.environmentId, environment.id),
)
.innerJoin(job, eq(releaseJobTrigger.jobId, job.id))
.innerJoin(release, eq(releaseJobTrigger.releaseId, release.id))
.where(
and(
eq(environmentPolicyApproval.id, envApproval.id),
isNull(environment.deletedAt),
eq(release.id, input.releaseId),
eq(job.status, JobStatus.Pending),
),
);

Expand Down

0 comments on commit 6104a79

Please sign in to comment.