Summary
This is a pull request for branch finals-use-search-endpoint.
This PR refactors the finals search functionality to use the existing /courses/search backend endpoint instead of client-side text filtering on the finals.json data.
Changes
New File: apps/frontend/src/app/api/finals.ts
- Added
useFetchFinalsSearch hook that calls the /courses/search endpoint with keywords
- Returns a list of matching courseIDs from the backend's full-text search
Updated: apps/frontend/src/components/finals/FinalsViewer.tsx
- Imports the new
useFetchFinalsSearch hook
- Uses React Query to fetch search results when user types in the search box
- Filters the finals.json data based on matching courseIDs from the search API
- Standardizes course IDs (e.g.,
48321A -> 48-321) for proper matching
- Maintains backward compatibility with the "own courses" filtering feature
Why?
Previously, the finals search was using client-side text filtering on the course code field in finals.json. This was limited because:
- It only searched the course code, not the course name or description
- Users couldn't find courses by course name (e.g., "Calculus" wouldn't find 21-120)
Now, the search uses the backend's full-text search which indexes:
- Course names
- Course descriptions
- Course IDs
This provides a much better search experience while still maintaining the local finals data for fast filtering of results.
Testing
- Type checking passes (no new TypeScript errors)
- The logic properly handles:
- No search query (shows all finals)
- Search with results (filters finals by matching courseIDs)
- Search with no results (shows empty state)
- Own courses filtering combined with search
Branch: finals-use-search-endpoint
Create PR at: https://github.com/ScottyLabs/cmucourses/pull/new/finals-use-search-endpoint
Summary
This is a pull request for branch
finals-use-search-endpoint.This PR refactors the finals search functionality to use the existing
/courses/searchbackend endpoint instead of client-side text filtering on the finals.json data.Changes
New File:
apps/frontend/src/app/api/finals.tsuseFetchFinalsSearchhook that calls the/courses/searchendpoint with keywordsUpdated:
apps/frontend/src/components/finals/FinalsViewer.tsxuseFetchFinalsSearchhook48321A->48-321) for proper matchingWhy?
Previously, the finals search was using client-side text filtering on the course code field in finals.json. This was limited because:
Now, the search uses the backend's full-text search which indexes:
This provides a much better search experience while still maintaining the local finals data for fast filtering of results.
Testing
Branch:
finals-use-search-endpointCreate PR at: https://github.com/ScottyLabs/cmucourses/pull/new/finals-use-search-endpoint