Skip to content

Commit

Permalink
fix: move professor name to sessions not course
Browse files Browse the repository at this point in the history
  • Loading branch information
shp2018 committed Feb 5, 2025
1 parent 4cc3a51 commit 108248c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 21 deletions.
6 changes: 0 additions & 6 deletions .env.example

This file was deleted.

31 changes: 16 additions & 15 deletions app/agents/scrapers/simon_fraser_university.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ async def fetch_courses(self) -> CourseListingModel:
current_course: CourseModel = {
"courseName": course.get('title'),
"courseCode": f"{program['programCode']} {course.get('text')}",
"professorName": None,
"credit": None,
"sessions": []
}
Expand All @@ -169,29 +168,31 @@ async def fetch_courses(self) -> CourseListingModel:
if not detail:
continue

# Update course credit and professor if not set yet
if current_course["credit"] is None and detail.get('info', {}).get('units'):
current_course["credit"] = float(detail.get('info', {}).get('units'))

if current_course["professorName"] is None:
instructors = detail.get('instructor', [])
if instructors:
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')

# Create a new session for this section
current_session: SessionModel = {
"sessionName": f"{section.get('sectionCode', '')} {section.get('text', '')}".strip(),
"professorName": None,
"campus": None,
"location": None,
"schedules": []
}

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

# Set professor name for this session
instructors = detail.get('instructor', [])
if instructors:
primary_instructor = next(
(i for i in instructors if i.get('roleCode') == 'PI'),
instructors[0] if instructors else None
)
if primary_instructor:
current_session["professorName"] = primary_instructor.get('name')

# Update course credit if not set yet
if current_course["credit"] is None and detail.get('info', {}).get('units'):
current_course["credit"] = float(detail.get('info', {}).get('units'))

for block in schedule_blocks:
if block.get('isExam'):
continue
Expand Down

0 comments on commit 108248c

Please sign in to comment.