-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: separate endpoint for holding pen status
feat: update client on when job has been pulled from queue
- Loading branch information
1 parent
dad26eb
commit 5a4a778
Showing
9 changed files
with
47 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
orchestrator/packages/api/src/controllers/holding-pen-controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Request, Response } from "express"; | ||
import { errorResponse } from "./utils"; | ||
import { jobConfigInHoldingPen } from "@codegrade-orca/db"; | ||
|
||
export const holdingPenStatus = async (req: Request, res: Response) => { | ||
const jobConfigID = parseInt(req.params.jobConfigID); | ||
if (isNaN(jobConfigID)) { | ||
return errorResponse(res, 400, [`Given job config ID ${jobConfigID} is not a number.`]); | ||
} | ||
if (await jobConfigInHoldingPen(jobConfigID)) { | ||
res.json("This job is waiting of a grader image to build."); | ||
} else { | ||
res.json("This job could not be found in a holding pen. Please contact an admin or professor."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Router } from "express"; | ||
import { holdingPenStatus } from "../controllers/holding-pen-controller"; | ||
|
||
const holdingPenRouter = Router(); | ||
|
||
holdingPenRouter.get("/holding_pen/:jobConfigID/status", holdingPenStatus); | ||
|
||
export default holdingPenRouter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import prismaInstance from '../prisma-instance'; | ||
|
||
export const jobConfigInHoldingPen = async (jobConfigID: number): Promise<boolean> => | ||
Boolean(await prismaInstance.jobConfigAwaitingImage.count({ where: { id: jobConfigID } })); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * from "./exceptions"; | ||
export * from "./server-operations"; | ||
export * from "./image-builder-operations"; | ||
export * from "./holding-pen-operations"; | ||
export * from "./shared"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters