Skip to content

Commit

Permalink
Merge pull request #1499 from argos-ci/optimize-query
Browse files Browse the repository at this point in the history
perf: optimize builds query
  • Loading branch information
gregberge authored Jan 2, 2025
2 parents 1e7dc74 + b8425d1 commit d76d5fb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion apps/backend/src/graphql/definitions/Project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { assertNever } from "@argos/util/assertNever";
import { invariant } from "@argos/util/invariant";
import * as Sentry from "@sentry/node";
import gqlTag from "graphql-tag";
import type { PartialModelObject } from "objection";
import { raw, type PartialModelObject } from "objection";

import {
Account,
Expand Down Expand Up @@ -516,6 +516,7 @@ export const resolvers: IResolvers = {
if (!status.includes(IBuildStatus.Accepted)) {
qb.whereNotExists(
ScreenshotDiff.query()
.select(raw("1"))
.whereRaw('screenshot_diffs."buildId" = builds.id')
.where("validationStatus", "accepted"),
);
Expand All @@ -524,6 +525,7 @@ export const resolvers: IResolvers = {
if (!status.includes(IBuildStatus.Rejected)) {
qb.whereNotExists(
ScreenshotDiff.query()
.select(raw("1"))
.whereRaw('screenshot_diffs."buildId" = builds.id')
.where("validationStatus", "rejected"),
);
Expand All @@ -535,6 +537,7 @@ export const resolvers: IResolvers = {
.orWhereNull("conclusion")
.orWhereExists(
ScreenshotDiff.query()
.select(raw("1"))
.whereRaw('screenshot_diffs."buildId" = builds.id')
.whereIn("validationStatus", ["rejected", "accepted"]),
);
Expand All @@ -547,6 +550,7 @@ export const resolvers: IResolvers = {
.orWhereNull("conclusion")
.orWhereExists(
ScreenshotDiff.query()
.select(raw("1"))
.whereRaw('screenshot_diffs."buildId" = builds.id')
.whereIn("validationStatus", ["rejected", "accepted"]),
);
Expand Down

0 comments on commit d76d5fb

Please sign in to comment.