Skip to content

Commit 82be7fd

Browse files
authored
Merge pull request #28 from CS3219-AY2425S1/PEER-213
PEER-213: Retrieve questions not attempted by users
2 parents 0c2e48d + 36c10bd commit 82be7fd

20 files changed

+2120
-408
lines changed

backend/question/drizzle/0000_initial_schema.sql renamed to backend/question/drizzle/0000_bizarre_midnight.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CREATE TABLE IF NOT EXISTS "questions" (
2-
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
2+
"id" serial PRIMARY KEY NOT NULL,
33
"title" varchar(255) NOT NULL,
44
"difficulty" varchar(50) NOT NULL,
55
"topic" varchar(255)[] NOT NULL,

backend/question/drizzle/0001_neat_skullbuster.sql

Lines changed: 0 additions & 1 deletion
This file was deleted.

backend/question/drizzle/0002_glorious_onslaught.sql

Lines changed: 0 additions & 1 deletion
This file was deleted.

backend/question/drizzle/meta/0000_snapshot.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"id": "36d01d6f-4eb8-4c12-a89f-89295da72dcc",
2+
"id": "537c03f5-13dd-427a-ae0d-cfd203da09ed",
33
"prevId": "00000000-0000-0000-0000-000000000000",
44
"version": "7",
55
"dialect": "postgresql",
@@ -10,10 +10,9 @@
1010
"columns": {
1111
"id": {
1212
"name": "id",
13-
"type": "uuid",
13+
"type": "serial",
1414
"primaryKey": true,
15-
"notNull": true,
16-
"default": "gen_random_uuid()"
15+
"notNull": true
1716
},
1817
"title": {
1918
"name": "title",

backend/question/drizzle/meta/0001_snapshot.json

Lines changed: 0 additions & 78 deletions
This file was deleted.

backend/question/drizzle/meta/0002_snapshot.json

Lines changed: 0 additions & 71 deletions
This file was deleted.

backend/question/drizzle/meta/_journal.json

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,8 @@
55
{
66
"idx": 0,
77
"version": "7",
8-
"when": 1727390805855,
9-
"tag": "0000_initial_schema",
10-
"breakpoints": true
11-
},
12-
{
13-
"idx": 1,
14-
"version": "7",
15-
"when": 1727504673110,
16-
"tag": "0001_neat_skullbuster",
17-
"breakpoints": true
18-
},
19-
{
20-
"idx": 2,
21-
"version": "7",
22-
"when": 1727510874424,
23-
"tag": "0002_glorious_onslaught",
8+
"when": 1727595727110,
9+
"tag": "0000_bizarre_midnight",
2410
"breakpoints": true
2511
}
2612
]

backend/question/src/controller/search-controller.ts renamed to backend/question/src/controller/question-controller.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
getQuestionDetailsService,
55
getRandomQuestionService,
66
searchQuestionsByTitleService,
7-
} from '../services/get/';
7+
} from '../services/get/index';
88
import {
99
IGetQuestionsPayload,
1010
IGetQuestionPayload,
@@ -43,11 +43,10 @@ export const getQuestionDetails = async (req: Request, res: Response): Promise<R
4343

4444
export const getRandomQuestion = async (req: Request, res: Response): Promise<Response> => {
4545
const payload: IGetRandomQuestionPayload = {
46-
userId: parseInt(req.params.userId),
47-
difficulty: req.query.difficulty as string,
48-
topic: req.query.topic as string[],
46+
attemptedQuestions: req.body.attemptedQuestions,
47+
difficulty: req.body.difficulty,
48+
topic: req.body.topic,
4949
};
50-
5150
try {
5251
const result = await getRandomQuestionService(payload);
5352
return res.status(result.code).json(result);

backend/question/src/lib/db/schema.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { pgTable, uuid, varchar, text, timestamp } from 'drizzle-orm/pg-core';
1+
import { pgTable, serial, varchar, text, timestamp } from 'drizzle-orm/pg-core';
22

33
export const questions = pgTable('questions', {
4-
id: uuid('id').primaryKey().defaultRandom(),
4+
id: serial('id').primaryKey(),
55
title: varchar('title', { length: 255 }).notNull(),
66
difficulty: varchar('difficulty', { length: 50 }).notNull(),
77
topic: varchar('topic', { length: 255 }).array().notNull(),

backend/question/src/routes/question-routes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
getQuestions,
55
getQuestionDetails,
66
getRandomQuestion,
7-
} from '../controller/search-controller';
7+
} from '../controller/question-controller';
88

99
const router = Router();
1010

@@ -14,6 +14,6 @@ router.get('/', getQuestions);
1414

1515
router.get('/:questionId', getQuestionDetails);
1616

17-
router.get('/random', getRandomQuestion);
17+
router.post('/random', getRandomQuestion);
1818

1919
export default router;

0 commit comments

Comments
 (0)