Skip to content

Commit

Permalink
chore: add professor name to course type
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiin Kim authored and Jiin Kim committed Jan 9, 2025
1 parent ab56fc2 commit e4eb40d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/agents/scrapers/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class Meta:
courseCode = factory.LazyFunction(
lambda: f"{fake.random_letter().upper()}{fake.random_letter().upper()}{fake.random_letter().upper()} {fake.random_int(min=100, max=499)}"
)
professorName = factory.Faker('name')
credit = factory.LazyFunction(lambda: random.choice([3, 4]))
sessions = factory.LazyFunction(lambda: [SessionFactory() for _ in range(random.randint(1, 3))])

Expand Down
12 changes: 12 additions & 0 deletions app/agents/scrapers/simon_fraser_university.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ async def fetch_courses(self) -> CourseListingModel:
current_course: CourseModel = {
"courseName": course.get('title'),
"courseCode": f"{program['programCode']} {course.get('text')}",
"professorName": None, # Will be updated from detail
"credit": None, # Credit info not available in API
"sessions": []
}
Expand All @@ -164,6 +165,17 @@ async def fetch_courses(self) -> CourseListingModel:
if not detail:
continue

# Get professor name from instructor info
instructors = detail.get('instructor', [])
if instructors:
# Get primary instructor if available, otherwise first instructor
primary_instructor = next(
(i for i in instructors if i.get('roleCode') == 'PI'),
instructors[0] if instructors else None
)
if primary_instructor:
current_course["professorName"] = primary_instructor.get('name')

schedule = detail.get('courseSchedule', [])

for block in schedule:
Expand Down
1 change: 1 addition & 0 deletions app/models/course.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class SessionModel(TypedDict):
class CourseModel(TypedDict):
courseName: Optional[str] # e.g. "Operating Systems"
courseCode: Optional[str] # e.g. "CMPT 300 D100"
professorName: Optional[str] # e.g. "John Doe"
credit: Optional[int]
sessions: List[SessionModel]

Expand Down

0 comments on commit e4eb40d

Please sign in to comment.