Skip to content

Commit

Permalink
perf: optimize query
Browse files Browse the repository at this point in the history
  • Loading branch information
gregberge committed Jun 16, 2024
1 parent 2477895 commit 36506a1
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions apps/backend/src/build/partial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,26 +115,24 @@ export async function finalizePartialBuilds(input: {
}

const builds = await Build.query()
.where("ciProvider", "github-actions")
.withGraphFetched("shards")
.where("runId", input.runId)
.where("runAttempt", input.runAttempt)
.where("ciProvider", "github-actions")
.where("jobStatus", "pending")
.where("partial", true)
.joinRelated("compareScreenshotBucket")
.where("compareScreenshotBucket.complete", false)
.withGraphFetched("shards");
.where("partial", true);

await Promise.all(
builds.map(async (build) => {
const previousBuild = await Build.query()
.where("builds.ciProvider", "github-actions")
.where("builds.projectId", build.projectId)
.joinRelated("compareScreenshotBucket")
.withGraphFetched("shards.screenshots.playwrightTraceFile")
.where("builds.runId", build.runId)
.where("builds.runAttempt", "<", build.runAttempt)
.where("builds.projectId", build.projectId)
.where("builds.name", build.name)
.joinRelated("compareScreenshotBucket")
.where("builds.ciProvider", "github-actions")
.where("builds.runAttempt", "<", build.runAttempt)
.where("compareScreenshotBucket.complete", true)
.withGraphFetched("shards.screenshots.playwrightTraceFile")
.orderBy("builds.runAttempt", "desc")
.first();

Expand Down

0 comments on commit 36506a1

Please sign in to comment.