Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
2837 commits
Select commit Hold shift + click to select a range
acdf494
Merge branch 'dev' into about-Yu-Cao
barrettruth Oct 21, 2024
4a11501
Merge pull request #896 from thecourseforum/about-Yu-Cao
barrettruth Oct 21, 2024
142e2e7
Merge pull request #887 from thecourseforum/adhoc/add-vi-back
hari-gajjala Oct 22, 2024
e19b738
added my picture and about
Oct 23, 2024
da25aa0
Merge pull request #904 from thecourseforum/about-namaikureishi
barrettruth Oct 23, 2024
1b38948
feat(docker): upgrade docker to 3.12
barrettruth Oct 23, 2024
ff4988e
Merge pull request #905 from thecourseforum/docker-upgrade
barrettruth Oct 23, 2024
b9fa33d
fix: use new fontawesome kit (old expired)
barrettruth Oct 23, 2024
e93e069
Merge branch 'dev' into fontawesome-cdn
barrettruth Oct 23, 2024
a4634d9
revert: gcp on 3.11
barrettruth Oct 23, 2024
836c46c
Merge pull request #907 from thecourseforum/revert-docker-upgrade
barrettruth Oct 23, 2024
86e12ea
Merge branch 'dev' into fontawesome-cdn
barrettruth Oct 23, 2024
6df7538
Merge pull request #906 from thecourseforum/fontawesome-cdn
barrettruth Oct 23, 2024
32a4174
Add extra error logs
junholee6a Oct 23, 2024
2bd4181
Merge pull request #909 from junholee6a/add-logs-2
barrettruth Oct 23, 2024
08fc3f1
fix(middleware): don't fetch DNE fields
barrettruth Oct 24, 2024
3d5fd0b
Merge pull request #910 from thecourseforum/fix-middleware-logging
barrettruth Oct 24, 2024
e73bb71
make and apply migrations
gckang Oct 24, 2024
e2cfb64
Merge branch 'master' into dev
ajnye Oct 24, 2024
0a702fd
Merge pull request #911 from thecourseforum/dev
ajnye Oct 24, 2024
699e5b1
added info and pfp
jo-hya Oct 25, 2024
e49e493
added info and pfp
sagunvenuganti Oct 27, 2024
bb8eaff
added info
sagunvenuganti Oct 27, 2024
07a8b3c
Added Info and Picture
ronitbatra Oct 27, 2024
71f012a
Added Picture
ronitbatra Oct 27, 2024
1c2b708
Merge pull request #916 from thecourseforum/about-ronit
kmd2zjw Oct 27, 2024
48b3b85
fixed conflict
sagunvenuganti Oct 27, 2024
7f5fd17
fix(style): remove text shadow gradients
barrettruth Oct 27, 2024
c1d4182
pfp and info merge conflict resolved
sagunvenuganti Oct 27, 2024
2202f15
adding shruti bala to about page
shrutibala1 Oct 28, 2024
b302a49
Merge pull request #918 from thecourseforum/about-shrutibala
barrettruth Oct 29, 2024
1addb45
Merge branch 'dev' into remove-shadow
barrettruth Oct 29, 2024
f4f3138
Merge branch 'dev' into about-sagunvenuganti
barrettruth Oct 29, 2024
f7ae375
Merge pull request #915 from thecourseforum/about-sagunvenuganti
barrettruth Oct 29, 2024
901835e
Merge branch 'dev' into about-joyce
barrettruth Oct 29, 2024
0e8a3e3
Merge pull request #914 from thecourseforum/about-joyce
barrettruth Oct 29, 2024
00a5b2a
Removed Extra Picture
ronitbatra Oct 29, 2024
5e26f57
Add ENG_Ronit_Batra.jpg
ronitbatra Oct 29, 2024
559e144
updated team_info.json
ronitbatra Oct 29, 2024
417d351
Deleted Picture not working
ronitbatra Oct 29, 2024
de2571d
Merge branch 'dev' into remove-shadow
barrettruth Oct 29, 2024
b58b0bf
Merge pull request #917 from thecourseforum/remove-shadow
barrettruth Oct 29, 2024
02caf5c
added open graphic protocol and twitter card meta tags
YuDavidCao Nov 3, 2024
3273f14
Merge branch 'dev' into issue-819-remove_instructor_website
barrettruth Nov 3, 2024
24bc7f2
fix(db): migrations
barrettruth Nov 3, 2024
1d75095
Merge branch 'dev' into issue-819-remove_instructor_website
barrettruth Nov 3, 2024
6b8a4b7
Merge pull request #881 from thecourseforum/issue-819-remove_instruct…
barrettruth Nov 3, 2024
3f2ba06
remove discord in ci file
gckang Nov 3, 2024
5d01a80
Merge pull request #923 from thecourseforum/remove-discord-from-ci
barrettruth Nov 3, 2024
fc2fb1f
Merge branch 'dev' into meta-tag
barrettruth Nov 3, 2024
0f66303
removed all instances of using discord
gckang Nov 3, 2024
8a69e7b
remove references to discord view
gckang Nov 3, 2024
a059d45
Merge branch 'dev' into remove-discord-from-ci
barrettruth Nov 3, 2024
6ab3931
Merge pull request #924 from thecourseforum/remove-discord-from-ci
barrettruth Nov 3, 2024
f55d345
Merge branch 'dev' into meta-tag
barrettruth Nov 3, 2024
92475dd
Merge pull request #920 from thecourseforum/meta-tag
barrettruth Nov 3, 2024
238edb1
fix: revert kit to new kit
barrettruth Nov 3, 2024
8b39551
Merge pull request #925 from thecourseforum/fix-fontawesome
barrettruth Nov 3, 2024
4d8cd6c
refactor(search): begin indices
barrettruth Oct 25, 2024
e8f5805
fix: proper trigram search over instructor model
artiehumphreys Nov 3, 2024
30fab7a
fix: increased similarity and better scoring
artiehumphreys Nov 3, 2024
73e622b
feat(instructors): improved logic for finding max similarity given a …
artiehumphreys Nov 3, 2024
5318b2e
fix: added new index for course searches
artiehumphreys Nov 3, 2024
ddba357
fix: lint
artiehumphreys Nov 3, 2024
d4e2a84
fix(tests): replace full_name() method with full_name instance variable
artiehumphreys Nov 3, 2024
39a83a1
Merge pull request #912 from thecourseforum/search/refactor
barrettruth Nov 4, 2024
204bbb1
fix: improved trigram search for courses
artiehumphreys Nov 4, 2024
ea9fc94
fix(search): simplified search and new index for course title
artiehumphreys Nov 4, 2024
e70257e
feat: refactor search to not use elasticsearch api
barrettruth Nov 4, 2024
0a10b16
fix(search): cleanup mean()
barrettruth Nov 4, 2024
2390370
fix(search): only pass necessary data to template
barrettruth Nov 4, 2024
233041f
chore: remove uncessary pprint import
barrettruth Nov 4, 2024
9f859d2
fix(style): prefer comprehensions to fp
barrettruth Nov 4, 2024
3616bbb
Merge branch 'dev' into issue-826-bar_chart_overflow
barrettruth Nov 4, 2024
4d622b3
Merge pull request #880 from thecourseforum/issue-826-bar_chart_overflow
barrettruth Nov 4, 2024
e386ab1
Merge branch 'dev' into rip-tino
barrettruth Nov 4, 2024
0567429
Merge pull request #875 from thecourseforum/rip-tino
barrettruth Nov 4, 2024
3213c02
Merge branch 'dev' into search/fetch_courses
barrettruth Nov 4, 2024
50da5c9
fix(search): add space for handling mnemonic number searches without …
artiehumphreys Nov 4, 2024
36a1a55
fix: comments
artiehumphreys Nov 4, 2024
16648c2
refactor(search): code cleanups
barrettruth Nov 4, 2024
eb5ada9
fix(search): improved threshold and lint
artiehumphreys Nov 4, 2024
badc6a8
Merge pull request #926 from thecourseforum/search/fetch_courses
barrettruth Nov 4, 2024
d3fc478
Merge branch 'dev' into search/refactor
barrettruth Nov 4, 2024
8c97313
fix(search): refactor + simplify search logic
barrettruth Nov 4, 2024
4893d10
fix(lint): remove unused arg
barrettruth Nov 4, 2024
cf2ea7c
fix: readability
artiehumphreys Nov 4, 2024
181884b
Merge pull request #927 from thecourseforum/search/refactor
barrettruth Nov 5, 2024
4ded517
fix: change all usages of full_name to be properties
barrettruth Nov 5, 2024
775b6c3
Merge pull request #929 from thecourseforum/fix-ci
ajnye Nov 5, 2024
6087ae5
fix(models): user has full name
barrettruth Nov 5, 2024
e9e9e0e
Merge branch 'dev' into fix-ci
barrettruth Nov 5, 2024
3de2cc5
Merge pull request #931 from thecourseforum/fix-ci
barrettruth Nov 5, 2024
33e3156
Merge pull request #928 from thecourseforum/dev
ayung0 Nov 5, 2024
1274e0e
Update master-to-app-engine.yml
ayung0 Nov 5, 2024
de3ae94
remove references to discord view
gckang Nov 3, 2024
b92fd52
removed all instances of using discord
gckang Nov 3, 2024
794c1f7
remove discord in ci file
gckang Nov 3, 2024
86ba75a
Test add
ajnye Nov 5, 2024
70cbea9
Revert test
ajnye Nov 5, 2024
af43b7b
Merge pull request #935 from thecourseforum/dev
ajnye Nov 5, 2024
f94b518
fix: python 3.11
barrettruth Nov 5, 2024
e8431a9
Merge pull request #939 from thecourseforum/fix-python-version
barrettruth Nov 5, 2024
ac99552
Merge pull request #940 from thecourseforum/fix-python-version
barrettruth Nov 5, 2024
dcf44a9
fix(scripts): use arg in reset db
barrettruth Nov 5, 2024
9af3b2a
Merge branch 'master' of https://github.com/thecourseforum/theCourseF…
ayung0 Nov 10, 2024
44feffc
Merge pull request #941 from thecourseforum/fix-db-reset
barrettruth Nov 10, 2024
66d4d48
Merge branch 'dev' into disciplines-csv
barrettruth Nov 10, 2024
6461282
fix: use older 2024_fall.csv
barrettruth Nov 10, 2024
add8db0
fix: more modest page sizes
barrettruth Nov 10, 2024
a7402bb
Merge pull request #952 from thecourseforum/page-sizes
barrettruth Nov 10, 2024
0cada31
Merge branch 'dev' into disciplines-csv
barrettruth Nov 11, 2024
6e57cf3
Merge pull request #884 from thecourseforum/disciplines-csv
barrettruth Nov 11, 2024
024fda6
Add CSV Files for new Sem classes
ayung0 Nov 13, 2024
8dcf8e4
Merge pull request #956 from thecourseforum/dev
barrettruth Nov 14, 2024
ced9815
feat: track db
barrettruth Nov 15, 2024
7586387
feat(db): track db with git-lfs
barrettruth Nov 15, 2024
35ca2f4
feat(scripts): one-command setup
barrettruth Nov 15, 2024
e7cf6f0
feat(setup): install script
barrettruth Nov 15, 2024
a5c9627
feat: temp use non-main branch
barrettruth Nov 15, 2024
c14ee0d
feat(setup): one-command install directions
barrettruth Nov 15, 2024
cbcb4ff
fix(setup): warn for proper branches on merge
barrettruth Nov 15, 2024
06928a8
fix(setup): proper build cmd
barrettruth Nov 15, 2024
8b81ff9
fix(setup): run db setup asynchronously
barrettruth Nov 15, 2024
bf2ff9b
feat: update script
barrettruth Nov 15, 2024
9566fe5
fixed pfp problem
sagunvenuganti Nov 17, 2024
b64672c
chore(deps-dev): bump cross-spawn from 7.0.3 to 7.0.6
dependabot[bot] Nov 18, 2024
18a8b9f
Removed dependencies from fontawesome
ayung0 Nov 19, 2024
417a179
Refactored static import + added missed images
ayung0 Nov 19, 2024
81541ee
Merge pull request #961 from thecourseforum/fontawesome-dependency-re…
barrettruth Nov 19, 2024
00597a8
feat(format): format
barrettruth Nov 19, 2024
9ed561e
Merge pull request #962 from thecourseforum/format
barrettruth Nov 19, 2024
8cc299f
Merge branch 'dev' into dependabot/npm_and_yarn/cross-spawn-7.0.6
barrettruth Nov 19, 2024
7073258
Merge branch 'dev' into about-ronit
barrettruth Nov 19, 2024
b16337b
Merge pull request #958 from thecourseforum/about-ronit
barrettruth Nov 19, 2024
a0d2cb4
Merge branch 'dev' into dependabot/npm_and_yarn/cross-spawn-7.0.6
barrettruth Nov 19, 2024
573bf50
Merge pull request #960 from thecourseforum/dependabot/npm_and_yarn/c…
barrettruth Nov 19, 2024
15a25f3
Merge pull request #963 from thecourseforum/dev
barrettruth Nov 19, 2024
2e6fdba
bye bye
barrettruth Nov 19, 2024
05ff19a
Merge pull request #964 from thecourseforum/about
barrettruth Nov 19, 2024
7218ed5
Merge pull request #965 from thecourseforum/dev
barrettruth Nov 19, 2024
c906160
Merge branch 'dev' into lfs-db
barrettruth Nov 21, 2024
cb55734
Merge pull request #957 from thecourseforum/lfs-db
barrettruth Nov 21, 2024
7758fe6
update branches
barrettruth Nov 25, 2024
6d94624
Merge branch 'dev' into lfs-db
barrettruth Nov 25, 2024
69f2f16
feat: also link git-lfs
barrettruth Nov 25, 2024
9b1ad8b
Merge branch 'dev' into lfs-db
barrettruth Nov 25, 2024
f293a31
Merge pull request #969 from thecourseforum/lfs-db
barrettruth Nov 25, 2024
104976f
remove secrets
barrettruth Nov 27, 2024
0ee39c0
Merge pull request #971 from thecourseforum/fix-db
barrettruth Nov 27, 2024
7b8b1cf
added deprecation warning to FlexiblePagination class
angadv12 Nov 11, 2024
55d480a
pylint fix
angadv12 Nov 11, 2024
0cc44fc
added pagination, improved ease of use by adding page number selector…
angadv12 Nov 18, 2024
1540893
added styling for pagination, and fixed logic to be dynamic based on …
angadv12 Nov 18, 2024
5b0a0fd
deprecated FlexiblePagination
angadv12 Nov 18, 2024
9a77b0f
changed reviews_per_page to 10 (changed to 3 for system testing)
angadv12 Nov 18, 2024
020c937
fix: removed newline in url and removed deprecated script
artiehumphreys Nov 22, 2024
5276e67
Delete db/latest.sql
barrettruth Jan 2, 2025
4eec172
updated fetch data with the changes made to sis api
Jay-Lalwani Jan 19, 2025
505930f
feat(about): shruti to alums
barrettruth Jan 19, 2025
40ca669
feat(about): ann to alums
barrettruth Jan 19, 2025
c29bff7
Merge pull request #976 from thecourseforum/update-fetch-data
barrettruth Jan 20, 2025
9cdb8a6
Merge branch 'dev' into sp25-about-updates
barrettruth Jan 20, 2025
dbf7971
Merge pull request #977 from thecourseforum/sp25-about-updates
barrettruth Jan 20, 2025
be9b65e
feat(data): 2025 spring grades
barrettruth Jan 20, 2025
e7b799b
branch created
angadv12 Jan 24, 2025
f7e739a
deprecated git lfs, added gdown
angadv12 Jan 25, 2025
38abd49
Made fixes to pie chart, updated chart.js version
ayung0 Jan 25, 2025
b930ac3
Fix ESLint build error
ayung0 Jan 26, 2025
7450ab6
Merge pull request #980 from thecourseforum/issue-652-mobile-pie-chart
hari-gajjala Jan 26, 2025
c7b42f8
Delete db/latest.sql
barrettruth Jan 2, 2025
c2b125b
feat(about): shruti to alums
barrettruth Jan 19, 2025
493ecae
feat(about): ann to alums
barrettruth Jan 19, 2025
43a322e
updated fetch data with the changes made to sis api
Jay-Lalwani Jan 19, 2025
dd8185a
feat(data): 2025 spring grades
barrettruth Jan 20, 2025
5f58f53
fix(course reviews): passing unit tests
artiehumphreys Jan 26, 2025
0b75280
Merge branch 'dev' into paginate-reviews
barrettruth Jan 26, 2025
37e0f2c
Merge pull request #974 from thecourseforum/paginate-reviews
barrettruth Jan 26, 2025
98a06e4
Merge pull request #983 from thecourseforum/master
barrettruth Jan 26, 2025
e9fc862
update about page
kmd2zjw Jan 27, 2025
4c9e2b2
Merge pull request #985 from thecourseforum/update-about-page
barrettruth Jan 28, 2025
2f4d409
Fixed writing new reviews
ayung0 Jan 28, 2025
b7b5836
Fixed user review page
ayung0 Jan 28, 2025
e3eb00f
Merge pull request #987 from thecourseforum/dev
ayung0 Jan 28, 2025
ee8eac7
Merge pull request #988 from thecourseforum/master
ayung0 Jan 28, 2025
efeea23
Merge branch 'dev' of https://github.com/thecourseforum/theCourseForu…
angadv12 Jan 29, 2025
fbcde2a
add gdown to requirements
angadv12 Jan 29, 2025
3a97802
--id deprecated in gdown, no longer needed to be passed
angadv12 Jan 29, 2025
157713b
Update dev.md to include gdown as prerequisite
angadv12 Jan 29, 2025
0e4acc7
deprecated lfs fully
angadv12 Jan 29, 2025
38e7bb1
Merge branch 'deprecate-lfs' of https://github.com/thecourseforum/the…
angadv12 Jan 29, 2025
0df4f62
upgraded uwsgi 2.0.23 -> 2.0.28 for ci django error testing
angadv12 Jan 29, 2025
1b17f47
update scripts
barrettruth Jan 30, 2025
5b61678
Delete .gitattributes
angadv12 Jan 30, 2025
ef15ce0
removed gdown from requirements.txt (only needed for setup.sh)
angadv12 Jan 30, 2025
85ee65b
Merge branch 'deprecate-lfs' of https://github.com/thecourseforum/the…
angadv12 Jan 30, 2025
9f310ea
Merge pull request #989 from thecourseforum/deprecate-lfs
barrettruth Jan 30, 2025
03b3de4
Fixed icons
ajnye Feb 2, 2025
56c0df8
added team pfp
angadv12 Feb 4, 2025
ac05c09
Merge pull request #999 from thecourseforum/about-Angad-Brar
barrettruth Feb 5, 2025
dfed1e7
Create 2024_fall.csv
ayung0 Feb 5, 2025
3fb745a
update grade data
ayung0 Feb 5, 2025
0bf612f
feat(reviews): Default sorting method for faster fetch times
artiehumphreys Feb 6, 2025
adee65e
fixed icons on several pagse
ayung0 Feb 7, 2025
00cf6da
Fixed up and down arrow switching
ayung0 Feb 7, 2025
04107da
(fix): differ number of ratings vs. number of comments/ratings
artiehumphreys Feb 9, 2025
e4a7b34
(nit
artiehumphreys Feb 9, 2025
5be02ed
(nit): naming
artiehumphreys Feb 9, 2025
549eee1
Merge pull request #1010 from thecourseforum/filter-empty-reviews
barrettruth Feb 9, 2025
1cbf5e6
Merge branch 'dev' into reviews-default-sorting
barrettruth Feb 9, 2025
1317d8e
Merge pull request #1008 from thecourseforum/reviews-default-sorting
barrettruth Feb 9, 2025
e341128
Merge branch 'dev' into issue-991-icon-fixes
barrettruth Feb 9, 2025
fe01db4
Merge pull request #1005 from thecourseforum/issue-991-icon-fixes
barrettruth Feb 9, 2025
7a60556
Added back in "view section"; arrow UI still missing
ajnye Feb 9, 2025
d4a1c3b
Created avg_gpa_history_by_course method which attaches to the instru…
deesig Feb 16, 2025
63fb8a2
Created avg_gpa_history_by_course method which attaches to the instru…
deesig Feb 16, 2025
edb72c6
Added gpa graph function to course_data.js
deesig Feb 16, 2025
2360dab
Added gpa graph function to course_data.js
deesig Feb 16, 2025
f87ea95
Current progress
deesig Feb 16, 2025
ddf3d35
Current progress
deesig Feb 16, 2025
7cbb7e7
really scrappy line chart
deesig Feb 16, 2025
5e03426
really scrappy line chart
deesig Feb 16, 2025
6e825f9
yeah!
deesig Feb 16, 2025
8f263d8
yeah!
deesig Feb 16, 2025
ba27bae
Merge branch 'dev' of https://github.com/thecourseforum/theCourseForu…
deesig Feb 16, 2025
594104a
Merge branch 'dev' of https://github.com/thecourseforum/theCourseForu…
deesig Feb 16, 2025
a2c2dff
Got rid of avg gpa per course per instructor and instead moving to br…
deesig Feb 16, 2025
40fcb6a
Got rid of avg gpa per course per instructor and instead moving to br…
deesig Feb 16, 2025
c72d146
Formatted the chart using a toy line chart on the course-instructor page
deesig Feb 23, 2025
1964236
Formatted the chart using a toy line chart on the course-instructor page
deesig Feb 23, 2025
9a189ab
Fixed .csv parser to work with different professors & fixed formattin…
deesig Apr 6, 2025
8ccedc2
Fixed .csv parser to work with different professors & fixed formattin…
deesig Apr 6, 2025
3417733
Tweaked formatting so it's like F23 instead of F 23
deesig Apr 6, 2025
7d0bd8c
Tweaked formatting so it's like F23 instead of F 23
deesig Apr 6, 2025
4e36ec6
Fixed the GPA trend - Spring should now go before Fall and added a No…
deesig Apr 10, 2025
04dd524
Fixed the GPA trend - Spring should now go before Fall and added a No…
deesig Apr 10, 2025
7f52f4f
Update styling for GPA graph
ayung0 Apr 10, 2025
db11ac0
Update styling for GPA graph
ayung0 Apr 10, 2025
18c7e36
Added sentiment chart
gthsun Apr 11, 2025
099ac27
Merge remote-tracking branch 'origin/avg_gpa_trend'
gthsun Apr 11, 2025
e5cb2f8
Accepted changes
gthsun Apr 11, 2025
e386b6a
Disabled onClick for line chart legend
deesig Apr 11, 2025
06eee79
formatting changes
ayung0 Apr 13, 2025
cd3a5fc
no review/grade data case handling
ayung0 Apr 13, 2025
87c26a5
update graphs
ayung0 Apr 27, 2025
758655c
Update course_professor.html
ayung0 Apr 27, 2025
12d1c1f
Update course_professor.html
ayung0 Apr 27, 2025
91d0ff4
Update course_professor.html
ayung0 Apr 27, 2025
297ea06
update gpa history graph
ayung0 Apr 27, 2025
a2861ae
updated with dev
ayung0 Oct 4, 2025
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
872,892 changes: 872,892 additions & 0 deletions db/latest.sql

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions tcf_website/management/commands/average_sentiments.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import os
import re
import pandas as pd

def extract_professor_name(professor_full):
return re.match(r'^[^()]+', professor_full).group().strip()

def extract_course_mnemonic(course_full):
return course_full.split(' |')[0].strip()
Comment on lines +5 to +9
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Handle missing instructor/course values safely

re.match(...).group() and .split() assume every CSV row has non-empty strings. Pandas will pass NaN (floats) for missing values, which makes re.match raise TypeError and breaks the command on real data. Guard the inputs or drop null rows before applying the regex/split so the pipeline continues even when data is incomplete.

Apply this diff to make the helpers resilient:

 def extract_professor_name(professor_full):
-    return re.match(r'^[^()]+', professor_full).group().strip()
+    if not isinstance(professor_full, str) or not professor_full.strip():
+        return ""
+    match = re.match(r"^[^()]+", professor_full)
+    return match.group().strip() if match else professor_full.strip()
 
 def extract_course_mnemonic(course_full):
-    return course_full.split(' |')[0].strip()
+    if not isinstance(course_full, str) or not course_full.strip():
+        return ""
+    return course_full.split(" |", 1)[0].strip()
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def extract_professor_name(professor_full):
return re.match(r'^[^()]+', professor_full).group().strip()
def extract_course_mnemonic(course_full):
return course_full.split(' |')[0].strip()
def extract_professor_name(professor_full):
if not isinstance(professor_full, str) or not professor_full.strip():
return ""
match = re.match(r"^[^()]+", professor_full)
return match.group().strip() if match else professor_full.strip()
def extract_course_mnemonic(course_full):
if not isinstance(course_full, str) or not course_full.strip():
return ""
return course_full.split(" |", 1)[0].strip()


def avg_sentiment_df_creator():
current_directory = os.path.dirname(os.path.abspath(__file__))
reviews_data_path = os.path.join(current_directory, "reviews_data", "reviews_data_with_sentiment.csv")
df = pd.read_csv(reviews_data_path)
df["instructor_name_only"] = df["instructor"].apply(extract_professor_name)
df["course_code_only"] = df["course"].apply(extract_course_mnemonic)
avg_sentiment_df = df.groupby(["instructor_name_only", "course_code_only"])["sentiment_score"].mean().reset_index()
return avg_sentiment_df

def query_average(df, professor, course):
result = df[(df["instructor_name_only"] == professor) & (df["course_code_only"] == course)]
if result.empty:
print("No data found for the given professor and course.")
else:
print(f"Average sentiment score for {professor} in {course}: {result['sentiment_score'].values[0]:.2f}")

if __name__ == "__main__":
avg_sentiment_df = avg_sentiment_df_creator()
print(avg_sentiment_df)

while True:
professor = input("Enter professor name (or type 'exit' to quit): ")
if professor.lower() == 'exit':
break
course = input("Enter course name (or type 'exit' to quit): ")
if course.lower() == 'exit':
break
query_average(avg_sentiment_df, professor, course)
Comment on lines +27 to +38
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Expose this logic via a proper Django management command

Because this module sits under management/commands/, Django expects a Command subclass. With only a __main__ block, python manage.py average_sentiments raises AttributeError: module ... has no attribute 'Command', so the command cannot run. Wrap the existing workflow in a BaseCommand implementation so it can be executed through Django’s management interface.

Apply this diff to add the command scaffold and optional interactive mode:

-import os
-import re
-import pandas as pd
+import os
+import re
+import pandas as pd
+from django.core.management.base import BaseCommand
 
@@
-def query_average(df, professor, course):
+def query_average(df, professor, course):
     result = df[(df["instructor_name_only"] == professor) & (df["course_code_only"] == course)]
     if result.empty:
         print("No data found for the given professor and course.")
     else:
         print(f"Average sentiment score for {professor} in {course}: {result['sentiment_score'].values[0]:.2f}")
 
-
-if __name__ == "__main__":
-    avg_sentiment_df = avg_sentiment_df_creator()
-    print(avg_sentiment_df)
-    
-    while True:
-        professor = input("Enter professor name (or type 'exit' to quit): ")
-        if professor.lower() == 'exit':
-            break
-        course = input("Enter course name (or type 'exit' to quit): ")
-        if course.lower() == 'exit':
-            break
-        query_average(avg_sentiment_df, professor, course)
+def interactive_loop(avg_sentiment_df):
+    print(avg_sentiment_df)
+    while True:
+        professor = input("Enter professor name (or type 'exit' to quit): ")
+        if professor.lower() == "exit":
+            break
+        course = input("Enter course name (or type 'exit' to quit): ")
+        if course.lower() == "exit":
+            break
+        query_average(avg_sentiment_df, professor, course)
+
+
+class Command(BaseCommand):
+    help = "Generate average sentiment scores for instructor-course pairs."
+
+    def add_arguments(self, parser):
+        parser.add_argument(
+            "--interactive",
+            action="store_true",
+            help="Print the dataframe and prompt for instructor/course lookups.",
+        )
+
+    def handle(self, *args, **options):
+        avg_sentiment_df = avg_sentiment_df_creator()
+        if options["interactive"]:
+            interactive_loop(avg_sentiment_df)
+        else:
+            self.stdout.write(avg_sentiment_df.to_string(index=False))

Loading
Loading