Skip to content
Merged
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
17 changes: 15 additions & 2 deletions backend/package-lock.json

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

36 changes: 28 additions & 8 deletions backend/seed-data/seed-students.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const preservedUserIds: string[] = [];

const sampleStudents = [
{
_id: "student_001",
email: "alex.chen@university.edu",
name: "Alex Chen",
profilePicture:
Expand All @@ -38,8 +39,10 @@ const sampleStudents = [
organizations: ["Computer Science Society"],
specializations: ["Web Systems"],
school: "Tech University",
shareProfile: true,
},
{
_id: "student_002",
email: "maya.patel@state.edu",
name: "Maya Patel",
profilePicture:
Expand All @@ -56,8 +59,10 @@ const sampleStudents = [
organizations: ["Women in STEM"],
specializations: ["Artificial Intelligence"],
school: "State University",
shareProfile: true,
},
{
_id: "student_003",
email: "jordan.smith@college.edu",
name: "Jordan Smith",
profilePicture:
Expand All @@ -66,16 +71,18 @@ const sampleStudents = [
linkedIn: "https://www.linkedin.com/in/jordansmith",
hobbies: ["Gaming", "Cooking"],
skills: ["Java", "C++", "Docker"],
major: "Software Engineering",
major: "Computer Science",
classLevel: "SOPHOMORE",
fieldOfInterest: ["Cybersecurity", "Embedded Systems"],
projects: ["Network Traffic Monitor"],
companiesOfInterest: ["Intel", "IBM"],
organizations: ["Cyber Defense Club"],
specializations: ["Infrastructure"],
school: "Institute of Technology",
shareProfile: false,
},
{
_id: "student_004",
email: "liam.nguyen@uni.edu",
name: "Liam Nguyen",
profilePicture:
Expand All @@ -84,16 +91,18 @@ const sampleStudents = [
linkedIn: "https://www.linkedin.com/in/liamnguyen",
hobbies: ["Basketball", "Guitar"],
skills: ["C#", "Unity", "Maya"],
major: "Game Design",
major: "Computer Science",
classLevel: "FRESHMAN",
fieldOfInterest: ["Game Development", "VR/AR"],
projects: ["2D Platformer"],
companiesOfInterest: ["Netflix", "Meta"],
organizations: ["Game Dev Guild"],
specializations: ["Interactive Media"],
school: "Academy of Arts",
shareProfile: true,
},
{
_id: "student_005",
email: "sarah.kim@global.edu",
name: "Sarah Kim",
profilePicture:
Expand All @@ -110,8 +119,10 @@ const sampleStudents = [
organizations: ["Finance Association"],
specializations: ["Econometrics"],
school: "Global Business School",
shareProfile: false,
},
{
_id: "student_006",
email: "oscar.rodriguez@tech.edu",
name: "Oscar Rodriguez",
profilePicture:
Expand All @@ -120,33 +131,37 @@ const sampleStudents = [
linkedIn: "https://www.linkedin.com/in/oscarrod",
hobbies: ["Cycling", "Baking"],
skills: ["JavaScript", "HTML/CSS", "Figma"],
major: "Digital Media",
major: "Visual Arts",
classLevel: "JUNIOR",
fieldOfInterest: ["UX/UI Design", "Product Management"],
projects: ["Smart Home App Design"],
companiesOfInterest: ["Airbnb", "Slack"],
organizations: ["Design Collective"],
specializations: ["User Experience"],
school: "Design Institute",
shareProfile: true,
},
{
_id: "student_007",
email: "chloe.wilson@state.edu",
name: "Chloe Wilson",
profilePicture: "https://images.unsplash.com/photo-1544005313-94ddf0286df2",
type: "STUDENT",
linkedIn: "https://www.linkedin.com/in/chloewilson",
hobbies: ["Yoga", "Volunteering"],
skills: ["Go", "Kubernetes", "AWS"],
major: "Cloud Architecture",
major: "Computer Science",
classLevel: "SENIOR",
fieldOfInterest: ["DevOps", "Site Reliability"],
projects: ["Automated CI/CD Pipeline"],
companiesOfInterest: ["Amazon", "Microsoft"],
organizations: ["Cloud Computing Group"],
specializations: ["Distrubuted Systems"],
specializations: ["Distributed Systems"],
school: "Western University",
shareProfile: true,
},
{
_id: "student_008",
email: "ethan.brown@poly.edu",
name: "Ethan Brown",
profilePicture:
Expand All @@ -155,48 +170,53 @@ const sampleStudents = [
linkedIn: "https://www.linkedin.com/in/ethanbrown",
hobbies: ["Chess", "Swimming"],
skills: ["Rust", "Assembly", "Verilog"],
major: "Computer Engineering",
major: "Computer Engineering (CSE)",
classLevel: "SOPHOMORE",
fieldOfInterest: ["Hardware Design", "Robotics"],
projects: ["FPGA Traffic Controller"],
companiesOfInterest: ["NVIDIA", "AMD"],
organizations: ["IEEE Student Branch"],
specializations: ["Microprocessors"],
school: "Polytechnic University",
shareProfile: false,
},
{
_id: "student_009",
email: "isabella.white@uni.edu",
name: "Isabella White",
profilePicture: "https://images.unsplash.com/photo-1554151228-14d9def656e4",
type: "STUDENT",
linkedIn: "https://www.linkedin.com/in/isabellawhite",
hobbies: ["Skiing", "Writing"],
skills: ["Swift", "CoreData", "Firebase"],
major: "Mobile Development",
major: "Computer Science",
classLevel: "FRESHMAN",
fieldOfInterest: ["iOS Development", "Mobile UX"],
projects: ["Task Tracker App"],
companiesOfInterest: ["Apple", "Spotify"],
organizations: ["App Developers Club"],
specializations: ["Interface Design"],
school: "Central University",
shareProfile: true,
},
{
_id: "student_10",
email: "noah.davis@college.edu",
name: "Noah Davis",
profilePicture: "https://images.unsplash.com/photo-1552058544-f2b08422138a",
type: "STUDENT",
linkedIn: "https://www.linkedin.com/in/noahdavis",
hobbies: ["Drums", "Tennis"],
skills: ["PHP", "Laravel", "MySQL"],
major: "Information Systems",
major: "Data Science",
classLevel: "JUNIOR",
fieldOfInterest: ["Business Analysis", "Database Management"],
projects: ["Inventory Management System"],
companiesOfInterest: ["Oracle", "Zoom"],
organizations: ["MIS Society"],
specializations: ["Information Security"],
school: "Business College",
shareProfile: false,
},
];

Expand Down
59 changes: 59 additions & 0 deletions backend/src/controllers/userController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ interface StudentResponse extends BaseUserResponse {
fieldOfInterest?: string[];
projects?: string[];
companiesOfInterest?: string[];
shareProfile?: boolean;
}

interface AlumniResponse extends BaseUserResponse {
Expand Down Expand Up @@ -178,6 +179,7 @@ export const getUserById = asyncHandler(
hobbies: foundUser.hobbies,
skills: foundUser.skills,
companiesOfInterest: foundUser.companiesOfInterest,
shareProfile: foundUser.shareProfile,
} as StudentResponse;
} else {
responseData = {
Expand Down Expand Up @@ -418,3 +420,60 @@ export const getAlumniSimilarities = asyncHandler(
});
},
);

// @desc Get students willing to share profile
// @route GET /api/users/student
// @access Private
export const getOpenStudents = asyncHandler(async (req, res, next) => {
const errors = validationResult(req);
if (!errors.isEmpty()) {
return next(createHttpError(400, validationErrorParser(errors)));
}

const { page, perPage, query, major } = matchedData(req, {
locations: ["query"],
});

const dbQuery = User.find({
type: UserType.Student,
shareProfile: true,
});

if (query) {
dbQuery.or([
{ name: { $regex: new RegExp(query, "i") } },
{ school: { $regex: new RegExp(query, "i") } },
{ major: { $regex: new RegExp(query, "i") } },
]);
}

if (major) {
const majorArray = major
.split(",")
.map((item: string) => item.trim())
.filter(Boolean);

if (majorArray.length > 0) {
dbQuery.where("major").in(majorArray);
}
}

// ensure count and paginate do not conflict
const countQuery = dbQuery.clone();

// count total results, populate company, and paginate in parallel
const [total, users] = await Promise.all([
countQuery.countDocuments(),
dbQuery
.skip(page * perPage)
.limit(perPage)
.exec(),
]);

res.status(200).json({
page,
perPage,
total,
data: users,
});
});
Loading
Loading