-
Notifications
You must be signed in to change notification settings - Fork 13
autocomplete feature for search #1186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
pelin-sayar
wants to merge
34
commits into
dev
Choose a base branch
from
autocomplete
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
1d5c6bf
autocomplete backend, js frontend, some html (needs work)
pelin-sayar d3c8869
feat(autocomplete): dry view and cursor hover for results
artiehumphreys eb56903
searchbar html and css fixes
brandonistfan f3e3470
lint fixes
brandonistfan c05c6ed
fix(styling): url import
artiehumphreys a5167c4
feat(autocomplete): autocomplete for clubs
artiehumphreys a08e602
fix(lint)
artiehumphreys e65d41f
fix(autocomplete): club results now show
artiehumphreys 6beb4c7
autocomplete backend, js frontend, some html (needs work)
pelin-sayar 95d802d
feat(autocomplete): dry view and cursor hover for results
artiehumphreys d303312
searchbar html and css fixes
brandonistfan 8676527
lint fixes
brandonistfan b01d419
fix(styling): url import
artiehumphreys 61ab588
feat(autocomplete): autocomplete for clubs
artiehumphreys e0033d4
fix(lint)
artiehumphreys c56b6c6
fix(autocomplete): club results now show
artiehumphreys 99bd7e8
Merge branch 'autocomplete' of https://github.com/thecourseforum/theC…
artiehumphreys 3db5b7f
autocomplete backend, js frontend, some html (needs work)
pelin-sayar acc20ec
feat(autocomplete): dry view and cursor hover for results
artiehumphreys 8cfee85
searchbar html and css fixes
brandonistfan 8bd2186
lint fixes
brandonistfan ce12097
fix(styling): url import
artiehumphreys eb5cde6
feat(autocomplete): autocomplete for clubs
artiehumphreys b7fa2cb
fix(lint)
artiehumphreys 66364e6
fix(autocomplete): club results now show
artiehumphreys d0709ba
feat(autocomplete): parallelizing course + instructor fetching
artiehumphreys 6d657e2
made results display dynamically depending on screen size, wrote test…
pelin-sayar e8b7f76
resolved merge conflicts
pelin-sayar 8e4780f
forgot MAX_RESULTS as a const so fixed that
pelin-sayar 1482bae
missed a conflict earlier should be good now
pelin-sayar 4445505
2 tests are failing, will look into more throughout the week
pelin-sayar f2744bd
autocomplete tests now work yayy
pelin-sayar b793d41
added docstring to test file
pelin-sayar cd1ad9a
added more docstrings to methods
pelin-sayar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,215 @@ | ||
| """DRF Serializers""" | ||
|
|
||
| from rest_framework import serializers | ||
|
|
||
| from ..models import ( | ||
| Club, | ||
| ClubCategory, | ||
| Course, | ||
| Department, | ||
| Instructor, | ||
| School, | ||
| Semester, | ||
| Subdepartment, | ||
| ) | ||
|
|
||
|
|
||
| class SemesterSerializer(serializers.ModelSerializer): | ||
| """DRF Serializer for Semester""" | ||
|
|
||
| season = serializers.SerializerMethodField() | ||
|
|
||
| def get_season(self, obj): | ||
| """Change the `season` field to TitleCase (or PascalCase)""" | ||
| return obj.season.title() | ||
|
|
||
| class Meta: | ||
| model = Semester | ||
| fields = "__all__" | ||
|
|
||
|
|
||
| class SchoolSerializer(serializers.ModelSerializer): | ||
| """DRF Serializer for School""" | ||
|
|
||
| class Meta: | ||
| model = School | ||
| fields = "__all__" | ||
|
|
||
|
|
||
| class DepartmentSerializer(serializers.ModelSerializer): | ||
| """DRF Serializer for Department""" | ||
|
|
||
| school = SchoolSerializer(read_only=True) | ||
|
|
||
| class Meta: | ||
| model = Department | ||
| fields = "__all__" | ||
|
|
||
|
|
||
| class SubdepartmentSerializer(serializers.ModelSerializer): | ||
| """DRF Serializer for Subdepartment""" | ||
|
|
||
| class Meta: | ||
| model = Subdepartment | ||
| fields = "__all__" | ||
|
|
||
|
|
||
| class CourseSerializer(serializers.ModelSerializer): | ||
| """DRF Serializer for Course""" | ||
|
|
||
| subdepartment = SubdepartmentSerializer(read_only=True) | ||
|
|
||
| class Meta: | ||
| model = Course | ||
| fields = "__all__" | ||
|
|
||
|
|
||
| class CourseSimpleStatsSerializer(CourseSerializer): | ||
| """DRF Serializer for Course including some review statistics""" | ||
|
|
||
| semester_last_taught = SemesterSerializer(read_only=True) | ||
| average_rating = serializers.FloatField(allow_null=True) | ||
| average_difficulty = serializers.FloatField(allow_null=True) | ||
| average_gpa = serializers.FloatField(allow_null=True) | ||
|
|
||
| class Meta: | ||
| model = Course | ||
| fields = [ | ||
| "id", | ||
| "title", | ||
| "description", | ||
| "number", | ||
| "subdepartment", | ||
| "semester_last_taught", | ||
| "average_rating", | ||
| "average_difficulty", | ||
| "average_gpa", | ||
| "is_recent", | ||
| ] | ||
|
|
||
|
|
||
| class CourseAllStatsSerializer(CourseSimpleStatsSerializer): | ||
| """DRF Serializer for Course including all review statistics""" | ||
|
|
||
| # ratings | ||
| average_instructor = serializers.FloatField(allow_null=True) | ||
| average_fun = serializers.FloatField(allow_null=True) | ||
| average_recommendability = serializers.FloatField(allow_null=True) | ||
| # workload | ||
| average_hours_per_week = serializers.FloatField(allow_null=True) | ||
| average_amount_reading = serializers.FloatField(allow_null=True) | ||
| average_amount_writing = serializers.FloatField(allow_null=True) | ||
| average_amount_group = serializers.FloatField(allow_null=True) | ||
| average_amount_homework = serializers.FloatField(allow_null=True) | ||
| # grades | ||
| a_plus = serializers.IntegerField(allow_null=True) | ||
| a = serializers.IntegerField(allow_null=True) | ||
| a_minus = serializers.IntegerField(allow_null=True) | ||
| b_plus = serializers.IntegerField(allow_null=True) | ||
| b = serializers.IntegerField(allow_null=True) | ||
| b_minus = serializers.IntegerField(allow_null=True) | ||
| c_plus = serializers.IntegerField(allow_null=True) | ||
| c = serializers.IntegerField(allow_null=True) | ||
| c_minus = serializers.IntegerField(allow_null=True) | ||
| dfw = serializers.IntegerField(allow_null=True) | ||
| total_enrolled = serializers.IntegerField(allow_null=True) | ||
|
|
||
| class Meta: | ||
| model = Course | ||
| fields = [ | ||
| "id", | ||
| "title", | ||
| "description", | ||
| "number", | ||
| "subdepartment", | ||
| "semester_last_taught", | ||
| "is_recent", | ||
| # ratings | ||
| "average_rating", | ||
| "average_instructor", | ||
| "average_fun", | ||
| "average_recommendability", | ||
| "average_difficulty", | ||
| # workload | ||
| "average_hours_per_week", | ||
| "average_amount_reading", | ||
| "average_amount_writing", | ||
| "average_amount_group", | ||
| "average_amount_homework", | ||
| # grades | ||
| "a_plus", | ||
| "a", | ||
| "a_minus", | ||
| "b_plus", | ||
| "b", | ||
| "b_minus", | ||
| "c_plus", | ||
| "c", | ||
| "c_minus", | ||
| "dfw", | ||
| "total_enrolled", | ||
| "average_gpa", | ||
| ] | ||
|
|
||
|
|
||
| class CourseAutocompleteSerializer(serializers.ModelSerializer): | ||
| """DRF Serializer for autocomplete course""" | ||
|
|
||
| subdepartment = serializers.CharField( | ||
| source="subdepartment.mnemonic", read_only=True | ||
| ) | ||
|
|
||
| class Meta: | ||
| model = Course | ||
| fields = ["id", "title", "number", "subdepartment"] | ||
|
|
||
|
|
||
| class InstructorSerializer(serializers.ModelSerializer): | ||
| """DRF Serializer for Instructor""" | ||
|
|
||
| class Meta: | ||
| model = Instructor | ||
| fields = "__all__" | ||
|
|
||
|
|
||
| class InstructorAutocompleteSerializer(serializers.ModelSerializer): | ||
| """DRF Serializer for autocomplete instructor""" | ||
|
|
||
| class Meta: | ||
| model = Instructor | ||
| fields = [ | ||
| "id", | ||
| "full_name", | ||
| ] | ||
|
|
||
|
|
||
| class ClubCategorySerializer(serializers.ModelSerializer): | ||
| """DRF Serializer for ClubCategory""" | ||
|
|
||
| class Meta: | ||
| model = ClubCategory | ||
| fields = "__all__" | ||
|
|
||
|
|
||
| class ClubSerializer(serializers.ModelSerializer): | ||
| """DRF Serializer for Club""" | ||
|
|
||
| category = ClubCategorySerializer(read_only=True) | ||
|
|
||
| class Meta: | ||
| model = Club | ||
| fields = "__all__" | ||
|
|
||
|
|
||
| class ClubAutocompleteSerializer(serializers.ModelSerializer): | ||
| """DEF Serializer for Club autocomplete""" | ||
|
|
||
| category_name = serializers.CharField(source="category.name", read_only=True) | ||
|
|
||
| class Meta: | ||
| model = Club | ||
| fields = ( | ||
| "id", | ||
| "name", | ||
| "category_name", | ||
| ) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix typo in docstring.
The docstring has "DEF Serializer" but should be "DRF Serializer" (Django REST Framework).
🔎 Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents