Skip to content

Commit

Permalink
fix: Latest active release check excludes skipped and cancelled
Browse files Browse the repository at this point in the history
  • Loading branch information
adityachoudhari26 committed Jan 13, 2025
1 parent 0d8dd62 commit 70e9da5
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions packages/job-dispatch/src/policies/release-sequencing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@ import { isAfter } from "date-fns";
import _ from "lodash";
import { isPresent } from "ts-is-present";

import { and, eq, inArray, isNull, ne, notExists, sql } from "@ctrlplane/db";
import {
and,
eq,
inArray,
isNull,
notExists,
notInArray,
sql,
} from "@ctrlplane/db";
import * as schema from "@ctrlplane/db/schema";
import { activeStatus, JobStatus } from "@ctrlplane/validators/jobs";

Expand Down Expand Up @@ -91,7 +99,13 @@ const latestActiveReleaseSubQuery = (db: Tx) =>
eq(schema.releaseJobTrigger.releaseId, schema.release.id),
)
.innerJoin(schema.job, eq(schema.releaseJobTrigger.jobId, schema.job.id))
.where(ne(schema.job.status, JobStatus.Pending))
.where(
notInArray(schema.job.status, [
JobStatus.Pending,
JobStatus.Skipped,
JobStatus.Cancelled,
]),
)
.as("active_releases");

/**
Expand Down

0 comments on commit 70e9da5

Please sign in to comment.