Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 32 additions & 22 deletions src/codingtest/codingtest.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Body, Controller, Get, Post, Req, UseGuards } from '@nestjs/common';
import { Body, Controller, Get, Post, Req, UseGuards, Patch, HttpException, HttpStatus } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { CodingTestService } from './codingtest.service';
import { CompileResultDto } from './dto/compileresult.dto';
Expand Down Expand Up @@ -32,28 +32,38 @@ export class CodingtestController {
}
}

@Post('/')
async getProblem(@Body('title') title: string) {
const problem = await this.codingTestService.getProblem(title);
return problem;
}

// @Post('/getProblem')
// async getProblem(@Body('problem_number') problem: number[]) {
// const problemInfo = await this.codingTestService.getProblem(problem);
// return problemInfo;
// }

// async

// //FOR TESTING
// @Get('testing')
// async insertProblemToDB() {
// await this.codingTestService.insertProblemToDB();
// }

}
@Post('/')
async getProblem(@Body('title') title: string) {
const problem = await this.codingTestService.getProblem(title);
return problem;
}

// @Post('/getProblem')
// async getProblem(@Body('problem_number') problem: number[]) {
// const problemInfo = await this.codingTestService.getProblem(problem);
// return problemInfo;
// }

// async

// //FOR TESTING
@Get('testing')
async insertProblemToDB() {
await this.codingTestService.insertProblemToDB();
}

// @Patch('update-limit-time')
// async updateProblemLimitTime(@Body() updateData: { number: number, limitTime: number }) {
// try {
// await this.codingTestService.updateProblemLimitTime(updateData.number, updateData.limitTime);
// return { status: 'Attempted to update problem.' };
// } catch (error) {
// console.error('An error occurred while updating the problem:', error);
// throw new HttpException('Internal server error', HttpStatus.INTERNAL_SERVER_ERROR);
// }
// }

}
/*python

input = sys.readline
Expand Down
10 changes: 10 additions & 0 deletions src/codingtest/codingtest.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,5 +199,15 @@ export class CodingTestService {
console.error('An error occurred while saving the problem:', error);
}
}

// async updateProblemLimitTime(problemNumber: number, limitTime: number) {
// try {
// await this.problemModel.updateOne({ number: problemNumber }, { $set: { limit_time: limitTime } }).exec();
// console.log('Attempted to update problem.');
// } catch (error) {
// console.error('An error occurred while updating the problem:', error);
// }
// }


}
3 changes: 3 additions & 0 deletions src/codingtest/schemas/codingtest.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ export class Problem extends Document {
@Prop()
@IsArray()
output: string[];

@Prop()
limit_time: number;
}
export const ProblemSchema = SchemaFactory.createForClass(Problem);

Expand Down