Skip to content

Commit

Permalink
fix: update UTDSchoolID and improve professor ID retrieval logic
Browse files Browse the repository at this point in the history
  • Loading branch information
GiridharRNair committed Jan 22, 2025
1 parent c9ed840 commit ed85481
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions api/professor/professor.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type Professor struct {
NumRatings int
}

const UTDSchoolID = "U2Nob29sLTEyNzM="
const UTDSchoolID = "1273"
const RateMyProfessorsGraphQLURL = "https://www.ratemyprofessors.com/graphql"
const RateMyProfessorSearchURL = "https://www.ratemyprofessors.com/search/professors/%s?q=%s"

Expand Down Expand Up @@ -100,10 +100,6 @@ func (p *Professor) getProfessorTags() {

func getProfessorID(professorName, schoolID string) (string, error) {
cleanedName := strings.ToLower(regexp.MustCompile(`[^a-zA-Z0-9]+`).ReplaceAllString(professorName, ""))
// Temporary fix for Wei-Pang Chin
if cleanedName == "weipangchin" {
return "2420900", nil
}

// Temporary fix for Bo Park
if cleanedName == "bopark" {
Expand All @@ -126,9 +122,14 @@ func getProfessorID(professorName, schoolID string) (string, error) {
re := regexp.MustCompile(`"legacyId":(\d+)`)
match := re.FindStringSubmatch(string(bodyBytes))

if len(match) > 1 && match[1] == schoolID {
return "", fmt.Errorf("Professor not found")
}

if len(match) > 1 {
return match[1], nil
}

return "", fmt.Errorf("Professor not found")
}

Expand Down

0 comments on commit ed85481

Please sign in to comment.