From 3ee094149cb48bf83a8c21090125f2316b0048f3 Mon Sep 17 00:00:00 2001 From: Zac Date: Sat, 23 Dec 2023 12:06:18 +0800 Subject: [PATCH] Add comment of cron job endpoint --- app/api/code/score/route.ts | 3 +++ app/api/code/submit/route.ts | 12 +----------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/app/api/code/score/route.ts b/app/api/code/score/route.ts index e5b062d..2790a9b 100644 --- a/app/api/code/score/route.ts +++ b/app/api/code/score/route.ts @@ -35,6 +35,9 @@ function deleteSubmissionFromDB(id: string) { return xata.db.SubmissionsMVP.delete(id); } +/* +Cron job endpoint that runs every minute. +*/ export async function POST() { const record = await xata.db.SubmissionsMVP.getFirst(); if (record) { diff --git a/app/api/code/submit/route.ts b/app/api/code/submit/route.ts index 8f224cb..7bd1039 100644 --- a/app/api/code/submit/route.ts +++ b/app/api/code/submit/route.ts @@ -18,17 +18,7 @@ export async function GET() { /* This is the entry point after code gets submitted. At the moment, this endpoint and its children endpoints are not protected. In the future, these routes need to be protected from DOS or spam attacks. -Warning: -This endpoint can get confusing because we've decoupled the functionalities we require into their own endpoints. The benefits of this approach is a decoupled service and easier debugging efforts. The downside is that it might be harder to reason with its correctness because of added complexity. Moreover, another downside is that every endpoint will need to be protected against DOS and spam attacks as mentioned above, which is a small overhead to the entire process. - -Flow: -User makes request -↓ User's wait ends in this step. -Increment the submit counter (api) -↓ -Make the call to the OpenAI wrapper (api) -↓ -On a successful OpenAI call, call the email generator (api) +This endpoint creates a record of the submission. Every minute, a cron job kicks off and processes a single submission at a time. */ export async function POST(req: Request) {