Skip to content

Commit b4317b7

Browse files
committed
Merge branch 'development' into BE/stopmatch
2 parents 315b0cd + bfa435e commit b4317b7

File tree

7 files changed

+73
-74
lines changed

7 files changed

+73
-74
lines changed

backend/matching-service/config/rabbitmq.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export const sendRabbitMq = async (
3232
try {
3333
const senderChannel = await mrConnection.createChannel();
3434
senderChannel.sendToQueue(queue, Buffer.from(JSON.stringify(data)));
35+
console.log("Sent to queue:", JSON.stringify(data));
3536
return true;
3637
} catch (error) {
3738
console.log(error);

backend/matching-service/src/utils/mq_utils.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ export const matchUsers = (newRequest: string) => {
3434
if (isMatch(newRequestJson, pendingRequest)) {
3535
matchingRequests.delete(uid);
3636
createMatch(pendingRequest, newRequestJson);
37+
console.log(
38+
"Matched users:",
39+
JSON.stringify(newRequestJson),
40+
JSON.stringify(pendingRequest)
41+
);
3742
return;
3843
}
3944
}

backend/question-service/src/controllers/questionController.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,24 @@ export const readCategories = async (
251251
res: Response,
252252
): Promise<void> => {
253253
try {
254-
const uniqueCats = await Question.distinct("category");
254+
// const uniqueCats = await Question.distinct("category");
255255

256+
// res.status(200).json({
257+
// message: CATEGORIES_RETRIEVED_MESSAGE,
258+
// categories: sortAlphabetically(uniqueCats),
259+
// });
256260
res.status(200).json({
257261
message: CATEGORIES_RETRIEVED_MESSAGE,
258-
categories: sortAlphabetically(uniqueCats),
262+
categories: sortAlphabetically([
263+
"Strings",
264+
"Algorithms",
265+
"Data Structures",
266+
"Bit Manipulation",
267+
"Recursion",
268+
"Dynamic Programming",
269+
"Arrays",
270+
"Tree",
271+
]),
259272
});
260273
} catch (error) {
261274
res.status(500).json({ message: SERVER_ERROR_MESSAGE, error });

backend/question-service/src/scripts/seed.ts

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,98 +11,84 @@ export async function seedQuestions() {
1111
description:
1212
"Design an algorithm to serialize and deserialize a binary tree. There is no restriction on how your serialization/deserialization algorithm should work. You just need to ensure that a binary tree can be serialized to a string and this string can be deserialized to the original tree structure. \n\n![image](https://firebasestorage.googleapis.com/v0/b/peerprep-c3bd1.appspot.com/o/07148757-21b2-4c20-93e0-d8bef1b3560d?alt=media)",
1313
complexity: "Hard",
14-
category: ["Tree", "Design"],
14+
category: ["Tree"],
1515
},
1616
{
1717
title: "Two Sum",
1818
description:
1919
"Given an array of integers `nums` and an integer `target`, return indices of the two numbers such that they add up to `target`. You may assume that each input would have **exactly one solution**, and you may not use the same element twice. You can return the answer in any order.",
2020
complexity: "Easy",
21-
category: ["Array", "Hash Table"],
22-
},
23-
{
24-
title: "Add Two Numbers",
25-
description:
26-
"You are given two non-empty linked lists representing two non-negative integers. The digits are stored in **reverse order**, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 itself.",
27-
complexity: "Medium",
28-
category: ["Linked List", "Math"],
21+
category: ["Arrays"],
2922
},
3023
{
3124
title: "Longest Substring Without Repeating Characters",
3225
description:
3326
"Given a string `s`, find the length of the **longest substring** without repeating characters.",
3427
complexity: "Medium",
35-
category: ["Hash Table", "Two Pointers", "String", "Sliding Window"],
28+
category: ["Strings"],
3629
},
3730
{
3831
title: "Median of Two Sorted Arrays",
3932
description:
4033
"Given two sorted arrays `nums1` and `nums2` of size `m` and `n` respectively, return the median of the two sorted arrays.",
4134
complexity: "Hard",
42-
category: ["Array", "Binary Search", "Divide and Conquer"],
35+
category: ["Arrays"],
4336
},
4437
{
4538
title: "Longest Palindromic Substring",
4639
description:
4740
"Given a string `s`, return the **longest palindromic substring** in `s`.",
4841
complexity: "Medium",
49-
category: ["String", "Dynamic Programming"],
42+
category: ["Strings", "Dynamic Programming"],
5043
},
5144
{
5245
title: "ZigZag Conversion",
5346
description:
5447
"The string `PAYPALISHIRING` is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then read line by line: `PAHNAPLSIIGYIR` Write the code that will take a string and make this conversion given a number of rows.",
5548
complexity: "Medium",
56-
category: ["String"],
49+
category: ["Strings"],
5750
},
5851
{
5952
title: "Reverse Integer",
6053
description:
6154
"Given a signed 32-bit integer `x`, return `x` with its digits reversed. If reversing `x` causes the value to go outside the signed 32-bit integer range `[-2^31, 2^31 - 1]`, then return 0.",
6255
complexity: "Easy",
63-
category: ["Math"],
56+
category: ["Strings"],
6457
},
6558
{
6659
title: "String to Integer (atoi)",
6760
description:
6861
"Implement the `myAtoi(string s)` function, which converts a string to a 32-bit signed integer (similar to C/C++'s `atoi` function).",
6962
complexity: "Medium",
70-
category: ["Math", "String"],
71-
},
72-
{
73-
title: "Palindrome Number",
74-
description:
75-
"Given an integer `x`, return `true` if `x` is a palindrome integer. An integer is a palindrome when it reads the same backward as forward. For example, `121` is palindrome while `123` is not.",
76-
complexity: "Easy",
77-
category: ["Math"],
63+
category: ["Strings"],
7864
},
7965
{
8066
title: "Regular Expression Matching",
8167
description:
8268
"Given an input string `s` and a pattern `p`, implement regular expression matching with support for `'.'` and `'*'` where: - `'.'` Matches any single character.​​​​ - `'*'` Matches zero or more of the preceding element.",
8369
complexity: "Hard",
84-
category: ["String", "Dynamic Programming", "Backtracking"],
70+
category: ["Strings", "Dynamic Programming"],
8571
},
8672
{
8773
title: "Container With Most Water",
8874
description:
8975
"Given `n` non-negative integers `a1, a2, ..., an`, where each represents a point at coordinate `(i, ai)`. `n` vertical lines are drawn such that the two endpoints of the line `i` is at `(i, ai)` and `(i, 0)`. Find two lines, which, together with the x-axis forms a container, such that the container contains the most water.",
9076
complexity: "Medium",
91-
category: ["Array", "Two Pointers"],
77+
category: ["Arrays"],
9278
},
9379
{
9480
title: "Integer to Roman",
9581
description:
9682
"Roman numerals are represented by seven different symbols: `I`, `V`, `X`, `L`, `C`, `D` and `M`. Given an integer, convert it to a roman numeral.",
9783
complexity: "Medium",
98-
category: ["Math", "String"],
84+
category: ["Strings"],
9985
},
10086
{
10187
title: "Roman to Integer",
10288
description:
10389
"Roman numerals are represented by seven different symbols: `I`, `V`, `X`, `L`, `C`, `D` and `M`. Given a roman numeral, convert it to an integer.",
10490
complexity: "Easy",
105-
category: ["Math", "String"],
91+
category: ["Strings"],
10692
},
10793
];
10894

frontend/src/components/QuestionCategoryAutoComplete/QuestionCategoryAutoComplete.test.tsx

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,33 +38,33 @@ describe("Question Category Auto Complete", () => {
3838
await waitFor(() => expect(screen.getByText("DFS")).toBeInTheDocument());
3939
});
4040

41-
it("Adding a new category not from the category list", async () => {
42-
const { rerender } = render(
43-
<QuestionCategoryAutoComplete
44-
selectedCategories={selectedCategories}
45-
setSelectedCategories={setSelectedCategories}
46-
/>
47-
);
41+
// it("Adding a new category not from the category list", async () => {
42+
// const { rerender } = render(
43+
// <QuestionCategoryAutoComplete
44+
// selectedCategories={selectedCategories}
45+
// setSelectedCategories={setSelectedCategories}
46+
// />
47+
// );
4848

49-
const input = screen.getByLabelText("Category");
50-
fireEvent.change(input, { target: { value: "New Category" } });
49+
// const input = screen.getByLabelText("Category");
50+
// fireEvent.change(input, { target: { value: "New Category" } });
5151

52-
const valueAdded = 'Add: "New Category"';
53-
expect(await screen.findByText(valueAdded)).toBeInTheDocument();
52+
// const valueAdded = 'Add: "New Category"';
53+
// expect(await screen.findByText(valueAdded)).toBeInTheDocument();
5454

55-
fireEvent.click(screen.getByText(valueAdded));
55+
// fireEvent.click(screen.getByText(valueAdded));
5656

57-
const updatedCategories = [...selectedCategories, "New Category"];
57+
// const updatedCategories = [...selectedCategories, "New Category"];
5858

59-
rerender(
60-
<QuestionCategoryAutoComplete
61-
selectedCategories={updatedCategories}
62-
setSelectedCategories={setSelectedCategories}
63-
/>
64-
);
59+
// rerender(
60+
// <QuestionCategoryAutoComplete
61+
// selectedCategories={updatedCategories}
62+
// setSelectedCategories={setSelectedCategories}
63+
// />
64+
// );
6565

66-
expect(screen.getByText("New Category")).toBeInTheDocument();
67-
});
66+
// expect(screen.getByText("New Category")).toBeInTheDocument();
67+
// });
6868

6969
it("Remove a category from selected categories", async () => {
7070
render(

frontend/src/components/QuestionCategoryAutoComplete/index.tsx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,31 @@ const QuestionCategoryAutoComplete: React.FC<
2424
return (
2525
<Autocomplete
2626
multiple
27-
freeSolo
2827
options={state.questionCategories}
2928
sx={{ marginTop: 2 }}
3029
value={selectedCategories}
3130
onChange={(_e, newCategoriesSelected) => {
32-
const newValue =
33-
newCategoriesSelected[newCategoriesSelected.length - 1];
34-
if (typeof newValue === "string" && newValue.startsWith(`Add: "`)) {
35-
const newCategory = newValue.slice(6, -1);
36-
state.questionCategories.push(newCategory);
37-
setSelectedCategories((prev) => [...prev, newCategory]);
38-
} else {
39-
setSelectedCategories(newCategoriesSelected);
40-
}
31+
// const newValue =
32+
// newCategoriesSelected[newCategoriesSelected.length - 1];
33+
// if (typeof newValue === "string" && newValue.startsWith(`Add: "`)) {
34+
// const newCategory = newValue.slice(6, -1);
35+
// state.questionCategories.push(newCategory);
36+
// setSelectedCategories((prev) => [...prev, newCategory]);
37+
// } else {
38+
// setSelectedCategories(newCategoriesSelected);
39+
// }
40+
setSelectedCategories(newCategoriesSelected);
4141
}}
4242
filterOptions={(options, params) => {
4343
const filtered = filter(options, params);
4444

45-
const { inputValue } = params;
45+
// const { inputValue } = params;
4646

47-
const isExisting = options.some((option) => inputValue === option);
47+
// const isExisting = options.some((option) => inputValue === option);
4848

49-
if (inputValue !== "" && !isExisting) {
50-
filtered.push(`Add: "${inputValue}"`);
51-
}
49+
// if (inputValue !== "" && !isExisting) {
50+
// filtered.push(`Add: "${inputValue}"`);
51+
// }
5252

5353
return filtered;
5454
}}

frontend/src/pages/Home/index.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const Home: React.FC = () => {
4949
}
5050
const { findMatch, loading } = match;
5151

52-
const isSmallerThan1100px = useMediaQuery('(max-width:1100px)');
52+
const isSmallerThan1100px = useMediaQuery("(max-width:1100px)");
5353

5454
useEffect(() => {
5555
getQuestionCategories(dispatch);
@@ -138,11 +138,9 @@ const Home: React.FC = () => {
138138
sx={{ backgroundColor: "white" }}
139139
>
140140
<Autocomplete
141-
multiple
142-
disableCloseOnSelect
143141
options={complexityList}
144142
onChange={(_, selectedOptions) => {
145-
setComplexities(selectedOptions);
143+
setComplexities(selectedOptions ? [selectedOptions] : []);
146144
}}
147145
renderInput={(params) => <TextField {...params} />}
148146
renderTags={(tagValue, getTagProps) =>
@@ -178,11 +176,9 @@ const Home: React.FC = () => {
178176
sx={{ backgroundColor: "white" }}
179177
>
180178
<Autocomplete
181-
multiple
182-
disableCloseOnSelect
183179
options={state.questionCategories}
184180
onChange={(_, selectedOptions) => {
185-
setCategories(selectedOptions);
181+
setCategories(selectedOptions ? [selectedOptions] : []);
186182
}}
187183
renderInput={(params) => <TextField {...params} />}
188184
renderTags={(tagValue, getTagProps) =>
@@ -218,11 +214,9 @@ const Home: React.FC = () => {
218214
sx={{ backgroundColor: "white" }}
219215
>
220216
<Autocomplete
221-
multiple
222-
disableCloseOnSelect
223217
options={languageList}
224218
onChange={(_, selectedOptions) => {
225-
setLanguages(selectedOptions);
219+
setLanguages(selectedOptions ? [selectedOptions] : []);
226220
}}
227221
renderInput={(params) => <TextField {...params} />}
228222
renderTags={(tagValue, getTagProps) =>

0 commit comments

Comments
 (0)