Skip to content

Commit

Permalink
PR fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jacquelinecai committed Nov 20, 2024
1 parent dcf9279 commit 1b1561d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
8 changes: 4 additions & 4 deletions client/src/modules/Admin/Components/Admin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const Admin = () => {
'empty' |
'semester' |
'profsReset' |
'profsUpdate' |
'professors' |
'subjects' |
'database' |
'description' |
Expand All @@ -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",
Expand Down Expand Up @@ -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');
}
Expand Down Expand Up @@ -439,7 +439,7 @@ export const Admin = () => {
</button>
{renderInitButton()}
</div >
</div >p[]
</div >

<ManageAdminModal
open={isAdminModalOpen}
Expand Down
1 change: 1 addition & 0 deletions server/scripts/populate-courses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,7 @@ const addSimilarityData = async (courses, course): Promise<boolean> => {
}
}

// threshold for tags
const threshold = (a, b) => {
if (b - a >= 0.5) {
return 'higher';
Expand Down
4 changes: 4 additions & 0 deletions server/src/admin/admin.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
24 changes: 15 additions & 9 deletions server/src/course/course.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand All @@ -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();

Expand All @@ -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 });
});

0 comments on commit 1b1561d

Please sign in to comment.