Skip to content

Commit

Permalink
Updated matcher algorithm updated the other
Browse files Browse the repository at this point in the history
  • Loading branch information
SurajjBhardwaj committed Feb 25, 2024
1 parent 23004c4 commit 54d2587
Show file tree
Hide file tree
Showing 10 changed files with 404 additions and 131 deletions.
20 changes: 20 additions & 0 deletions models/userModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ const expertiseSchema = new mongoose.Schema({
topics: [String], // Assuming topics is an array of strings
});


const querySchema = new mongoose.Schema({
language: {
type: String,
},
level: {
type: String,
enum: ["Exploring", "Beginner", "Intermediate", "Expert"],
},
topics: [String],
});

const userSchema = new mongoose.Schema(
{
name: {
Expand Down Expand Up @@ -70,6 +82,10 @@ const userSchema = new mongoose.Schema(
type: Boolean,
default: false,
},
roomName: {
type: String,
default: "",
}
},
messages: [
{
Expand All @@ -81,6 +97,10 @@ const userSchema = new mongoose.Schema(
type: Boolean,
default: false,
},
connectionType: {
type: String,
},
query: querySchema,
expertise: [expertiseSchema],
streaks: [streakSchema], // Adding streaks to the user schema
},
Expand Down
259 changes: 136 additions & 123 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"lint": "next lint"
},
"dependencies": {
"@hookform/resolvers": "^3.3.4",
"@headlessui/react": "^1.7.18",
"@heroicons/react": "^2.1.1",
"@hookform/resolvers": "^3.3.4",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-avatar": "^1.0.4",
"@radix-ui/react-dialog": "^1.0.5",
Expand Down Expand Up @@ -42,6 +42,7 @@
"tailwind-merge": "^2.2.1",
"tailwindcss": "3.4.1",
"tailwindcss-animate": "^1.0.7",
"uuid": "^9.0.1",
"zod": "^3.22.4"
}
}
32 changes: 32 additions & 0 deletions pages/api/leave.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import userModel from "@/models/userModel";
import connectDB from "@/lib/connectDB";


export async function handleLeave(req, res) {

try {

const { socketId } = req.body;

await connectDB();
const user = await userModel.findOne({ "socketInfo.id": socketId });

if (!user) {
return res.status(400).json({ success: false, message: "User not found" });
}



user.socketInfo.online = false;
user.socketInfo.roomName = "";
user.socketInfo.id = "";

await user.save();

res.status(200).json({ success: true, message: "User left the room" });
} catch (error) {
console.log(error);
res.status(400).json({ success: false, message: error.message });
}

}
Loading

0 comments on commit 54d2587

Please sign in to comment.