Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions app/routers/course.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ def search_course_query(
Course.desc_text,
Course.credit_min,
Course.credit_max,
func.group_concat(
distinct(
func.concat(Course_Offering.semester, " ", Course_Offering.sem_year)
)
).label("sem_list"),
func.group_concat(distinct(Course_Offering.semester)).label("sem_list"),
func.group_concat(distinct(Course_Attribute.attr_code)).label("attr_list"),
func.regexp_like(
func.concat(Course.subj_code, " ", Course.code_num),
Expand Down Expand Up @@ -148,7 +144,7 @@ def search_course(
deptFilters: str | None = None,
attrFilters: str | None = None,
semFilters: str | None = None,
) -> list[dict[str, str | int | None]]:
) -> list[dict[str, str | int | list[str]]]:
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return type annotation is incomplete. It should include None as a possible type for the dictionary values since subj_code, code_num, title, desc_text, credit_min, and credit_max can potentially be None. Consider updating to: list[dict[str, str | int | list[str] | None]]

Suggested change
) -> list[dict[str, str | int | list[str]]]:
) -> list[dict[str, str | int | list[str] | None]]:

Copilot uses AI. Check for mistakes.
# FastAPI does not support list query parameters
dept_filters = deptFilters.split(",") if deptFilters else None
attr_filters = attrFilters.split(",") if attrFilters else None
Expand Down Expand Up @@ -214,7 +210,13 @@ def search_course(
sem_filter_regex,
)
).all()
return [dict(row._mapping) for row in results]
results_dict = [dict(row._mapping) for row in results]
for course in results_dict:
course["sem_list"] = course["sem_list"].split(",") if course["sem_list"] else []
course["attr_list"] = (
course["attr_list"].split(",") if course["attr_list"] else []
)
return results_dict


@router.get("/filter/values/{filter}")
Expand Down
Loading