From 2e84bcc392184546dadd901c575da1af9cd28127 Mon Sep 17 00:00:00 2001 From: George-Zhang5246 <70183314+George-Zhang5246@users.noreply.github.com> Date: Tue, 29 Oct 2024 20:08:25 -0500 Subject: [PATCH 1/2] Update ratemyprofessorScraper.ts ratemyprofessorScraper now gives an error if the number of ratings is 0. --- src/pages/api/ratemyprofessorScraper.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/pages/api/ratemyprofessorScraper.ts b/src/pages/api/ratemyprofessorScraper.ts index 6a5a11c..c5110c7 100644 --- a/src/pages/api/ratemyprofessorScraper.ts +++ b/src/pages/api/ratemyprofessorScraper.ts @@ -146,10 +146,14 @@ export default function handler( maxRatingsProfessor = professors[i]; } } - res.status(200).json({ - message: 'success', - data: maxRatingsProfessor.node, - }); + if (maxRatingsProfessor.node.numRatings > 0) { + res.status(200).json({ + message: 'success', + data: maxRatingsProfessor.node, + }); + } else { + res.status(400).json({ message: error.message }); + } resolve(); return; }) From 1b6505dd454862e9de9065175089910a535220fb Mon Sep 17 00:00:00 2001 From: George-Zhang5246 <70183314+George-Zhang5246@users.noreply.github.com> Date: Tue, 29 Oct 2024 20:12:33 -0500 Subject: [PATCH 2/2] Update ratemyprofessorScraper.ts fixed --- src/pages/api/ratemyprofessorScraper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/api/ratemyprofessorScraper.ts b/src/pages/api/ratemyprofessorScraper.ts index c5110c7..e60f40c 100644 --- a/src/pages/api/ratemyprofessorScraper.ts +++ b/src/pages/api/ratemyprofessorScraper.ts @@ -152,7 +152,7 @@ export default function handler( data: maxRatingsProfessor.node, }); } else { - res.status(400).json({ message: error.message }); + res.status(400).json({ message: 'Data for professor not found' }); } resolve(); return;