Skip to content

Commit

Permalink
fix: Break out release channel into subquery
Browse files Browse the repository at this point in the history
  • Loading branch information
adityachoudhari26 committed Feb 28, 2025
1 parent bf81f69 commit b92854e
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions packages/job-dispatch/src/policies/release-sequencing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,24 @@ const isReleaseLatestActiveForEnvironment = async (
release: schema.Release,
environmentId: string,
) => {
const releaseChannelSubquery = db
.select()
.from(schema.environmentPolicyReleaseChannel)
.innerJoin(
schema.releaseChannel,
eq(
schema.environmentPolicyReleaseChannel.channelId,
schema.releaseChannel.id,
),
)
.where(
eq(
schema.environmentPolicyReleaseChannel.deploymentId,
release.deploymentId,
),
)
.as("release_channel");

const environment = await db
.select()
.from(schema.environment)
Expand All @@ -93,20 +111,10 @@ const isReleaseLatestActiveForEnvironment = async (
eq(schema.environment.policyId, schema.environmentPolicy.id),
)
.leftJoin(
schema.environmentPolicyReleaseChannel,
releaseChannelSubquery,
eq(
schema.environmentPolicyReleaseChannel.policyId,
schema.environmentPolicy.id,
),
)
.leftJoin(
schema.releaseChannel,
and(
eq(
schema.environmentPolicyReleaseChannel.channelId,
schema.releaseChannel.id,
),
eq(schema.releaseChannel.deploymentId, release.deploymentId),
releaseChannelSubquery.environment_policy_release_channel.policyId,
),
)
.where(eq(schema.environment.id, environmentId))
Expand Down Expand Up @@ -144,7 +152,7 @@ const isReleaseLatestActiveForEnvironment = async (
eq(schema.releaseJobTrigger.environmentId, environmentId),
schema.releaseMatchesCondition(
db,
environment.release_channel?.releaseFilter,
environment.release_channel?.release_channel.releaseFilter,
),
),
)
Expand Down

0 comments on commit b92854e

Please sign in to comment.