Skip to content

Commit

Permalink
more fix
Browse files Browse the repository at this point in the history
  • Loading branch information
adityachoudhari26 committed Jan 29, 2025
1 parent 30092ca commit da10ddb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion apps/jobs/src/policy-checker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export const run = async () => {
eq(schema.environmentPolicy.approvalRequirement, "automatic"),
eq(schema.environmentPolicyApproval.status, "approved"),
);
const isJobPending = eq(schema.job.status, JobStatus.Pending);
const isActiveResource = isNull(schema.resource.deletedAt);

const releaseJobTriggers = await db
.select()
Expand All @@ -24,6 +26,10 @@ export const run = async () => {
schema.environment,
eq(schema.releaseJobTrigger.environmentId, schema.environment.id),
)
.innerJoin(
schema.resource,
eq(schema.releaseJobTrigger.resourceId, schema.resource.id),
)
.leftJoin(
schema.environmentPolicy,
eq(schema.environment.policyId, schema.environmentPolicy.id),
Expand All @@ -41,7 +47,7 @@ export const run = async () => {
),
),
)
.where(and(eq(schema.job.status, JobStatus.Pending), isPassingApprovalGate))
.where(and(isJobPending, isPassingApprovalGate, isActiveResource))
.then((rows) => rows.map((row) => row.release_job_trigger));

if (releaseJobTriggers.length === 0) return;
Expand Down

0 comments on commit da10ddb

Please sign in to comment.