Skip to content

Commit

Permalink
feat: different status for image being built vs waiting for build
Browse files Browse the repository at this point in the history
  • Loading branch information
williams-jack committed Jul 14, 2024
1 parent 43a4fe7 commit 7de00a0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { errorResponse } from "./utils";
import {
validations,
} from "@codegrade-orca/common";
import { GradingQueueOperationException, enqueueImageBuild, imageIsBeingBuilt } from "@codegrade-orca/db";
import { GradingQueueOperationException, enqueueImageBuild, imageIsAwaitingBuild, imageIsBeingBuilt } from "@codegrade-orca/db";
import { graderImageExists } from "../utils/grader-images";

export const createGraderImage = async (req: Request, res: Response) => {
Expand Down Expand Up @@ -33,6 +33,8 @@ export const getImageBuildStatus = async (req: Request, res: Response) => {
res.json(`Image ${dockerfileSHA} is ready to be used for gradng.`);
} else if (await imageIsBeingBuilt(dockerfileSHA)) {
res.json(`Image ${dockerfileSHA} is in the process of being built.`);
} else if (await imageIsAwaitingBuild(dockerfileSHA)) {
res.json(`Image ${dockerfileSHA} is waiting to be built.`);
} else {
res.json(`No image ${dockerfileSHA} exists on the server.`);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import prismaInstance from "../prisma-instance"

export const imageIsBeingBuilt = async (dockerfileSHA: string): Promise<boolean> =>
await (prismaInstance.imageBuildInfo.count({ where: { dockerfileSHA, inProgress: true }})) > 0

export const imageIsAwaitingBuild = async (dockerfileSHA: string): Promise<boolean> =>
await (prismaInstance.imageBuildInfo.count({ where: { dockerfileSHA, inProgress: false }})) > 0
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import getNextImageBuild from "./get-next-image-build";
import handleCompletedImageBuild from "./handle-completed-image-build";
import imageIsBeingBuilt from "./image-being-built";

export { getNextImageBuild };
export { handleCompletedImageBuild };
export { imageIsBeingBuilt };
export * from "./image-build-status";

0 comments on commit 7de00a0

Please sign in to comment.