Skip to content

Commit

Permalink
Merge pull request #1416 from argos-ci/fix-empty-query
Browse files Browse the repository at this point in the history
fix: fix empty query
  • Loading branch information
gregberge authored Nov 12, 2024
2 parents 81f9da4 + 56d730b commit b0721b1
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions apps/backend/src/build/partial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,25 +176,27 @@ export async function finalizePartialBuilds(input: {
)
.returning("id");

await Screenshot.query().insert(
missingShards.flatMap((shard, index) => {
const insertedShard = insertedShards[index];
invariant(insertedShard, "Inserted shard should be found");
invariant(shard.screenshots, "Screenshots should be fetched");
return shard.screenshots.map((screenshot) => {
return {
name: screenshot.name,
s3Id: screenshot.s3Id,
screenshotBucketId: build.compareScreenshotBucketId,
fileId: screenshot.fileId,
testId: screenshot.testId,
metadata: screenshot.metadata,
playwrightTraceFileId: screenshot.playwrightTraceFileId,
buildShardId: insertedShard.id,
};
});
}),
);
const missingScreenshots = missingShards.flatMap((shard, index) => {
const insertedShard = insertedShards[index];
invariant(insertedShard, "Inserted shard should be found");
invariant(shard.screenshots, "Screenshots should be fetched");
return shard.screenshots.map((screenshot) => {
return {
name: screenshot.name,
s3Id: screenshot.s3Id,
screenshotBucketId: build.compareScreenshotBucketId,
fileId: screenshot.fileId,
testId: screenshot.testId,
metadata: screenshot.metadata,
playwrightTraceFileId: screenshot.playwrightTraceFileId,
buildShardId: insertedShard.id,
};
});
});

if (missingScreenshots.length > 0) {
await Screenshot.query().insert(missingScreenshots);
}

await finalizeBuild({ build });
await buildJob.push(build.id);
Expand Down

0 comments on commit b0721b1

Please sign in to comment.