From 1b1561d4ae4e0e53b81d5d05acaa6fc5722043d6 Mon Sep 17 00:00:00 2001 From: Jacqueline Date: Wed, 20 Nov 2024 18:22:14 -0500 Subject: [PATCH] PR fixes --- client/src/modules/Admin/Components/Admin.tsx | 8 +++---- server/scripts/populate-courses.ts | 1 + server/src/admin/admin.router.ts | 4 ++++ server/src/course/course.router.ts | 24 ++++++++++++------- 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/client/src/modules/Admin/Components/Admin.tsx b/client/src/modules/Admin/Components/Admin.tsx index df6eec32..c9c47941 100644 --- a/client/src/modules/Admin/Components/Admin.tsx +++ b/client/src/modules/Admin/Components/Admin.tsx @@ -27,7 +27,7 @@ export const Admin = () => { 'empty' | 'semester' | 'profsReset' | - 'profsUpdate' | + 'professors' | 'subjects' | 'database' | 'description' | @@ -37,7 +37,7 @@ export const Admin = () => { 'empty': '', 'semester': "New semester data successfully added", 'profsReset': "Professor data successfully reset to empty", - 'profsUpdate': "Professor data successfully updated", + 'professors': "Professor data successfully updated", 'subjects': "Subject full name data successfully updated", 'database': "Database successfully initialized", 'description': "Course description data successfully added", @@ -246,7 +246,7 @@ export const Admin = () => { if (response.status === 200) { console.log('Updated the professors'); setUpdating(false); - setUpdated('profsUpdate'); + setUpdated('professors'); } else { console.log('Error at setProfessors'); } @@ -439,7 +439,7 @@ export const Admin = () => { {renderInitButton()} - p[] + => { } } +// threshold for tags const threshold = (a, b) => { if (b - a >= 0.5) { return 'higher'; diff --git a/server/src/admin/admin.router.ts b/server/src/admin/admin.router.ts index 4395976e..7ad44639 100644 --- a/server/src/admin/admin.router.ts +++ b/server/src/admin/admin.router.ts @@ -484,6 +484,10 @@ adminRouter.post('/db/initialize', async (req, res) => { } }); +/** Reachable at POST /api/admin/rec/similarity + * @body token: a session's current token + * Populates the course database with similarity data. For admins only + */ adminRouter.post('/rec/similarity', async (req, res) => { const { token }: AdminRequestType = req.body; try { diff --git a/server/src/course/course.router.ts b/server/src/course/course.router.ts index ceb72e03..f2c4460d 100644 --- a/server/src/course/course.router.ts +++ b/server/src/course/course.router.ts @@ -70,7 +70,11 @@ courseRouter.post('/get-reviews', async (req, res) => { } }); -courseRouter.post('/getRecData', async (req, res) => { +/** Reachable at POST /api/courses/get-rec-metadata + * @body number, subject: a course's subject and number field + * Gets the array of all recommendation metadata for a specified course + */ +courseRouter.post('/get-rec-metadata', async (req, res) => { try { const { number, subject }: CourseInfoRequestType = req.body; const course = await getRecommendationData({ number, subject }); @@ -89,7 +93,10 @@ courseRouter.post('/getRecData', async (req, res) => { } }); -courseRouter.post('/getGlobal', async (req, res) => { +/** Reachable at POST /api/courses/get-global-metadata + * Gets the document containing all global metadata for courses + */ +courseRouter.post('/get-global-metadata', async (req, res) => { try { const global = await getGlobalMetadata(); @@ -101,23 +108,22 @@ courseRouter.post('/getGlobal', async (req, res) => { } }); -/** Reachable at POST /api/courses/getPreDesc +/** Reachable at POST /api/courses/preprocess-desc * @body description: a course description * Gets the processed description to use for the similarity algorithm * Currently used for testing */ -courseRouter.post('/getPreDesc', async (req, res) => { +courseRouter.post('/preprocess-desc', async (req, res) => { const { description }: CourseDescriptionRequestType = req.body; const processed = getProcessedDescription(description); return res.status(200).json({ result: processed }); }); -/** Reachable at POST /api/courses/getSimilarity - * @body courseId: a course's id field - * Gets the array of the top 5 similar courses for the course with id = courseId +/** Reachable at POST /api/courses/mock-similarity + * Gets the array of the top 5 similar courses + * Currently used for testing */ -courseRouter.post('/getSimilarity', async (req, res) => { - // const { courseId }: CourseIdRequestType = req.body; +courseRouter.post('/mock-similarity', async (req, res) => { const similarity = await getSimilarity(); return res.status(200).json({ result: similarity }); });