Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
AaDalal committed Oct 26, 2023
1 parent a4048c5 commit 19caff4
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
11 changes: 11 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]

[dev-packages]

[requires]
python_version = "3.10"
4 changes: 2 additions & 2 deletions backend/review/import_utils/parse_sql.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import gc
import re
from datetime import datetime
from courses.util import translate_semester_inv, semester_suffix_map_inv

from lark import Lark, Transformer
from tqdm import tqdm

from courses.util import semester_suffix_map_inv, translate_semester_inv


"""
This file contains functionality for parsing the SQL dump files that we get from ISC.
Expand Down Expand Up @@ -82,7 +83,6 @@ def row(self, items):
row_dict["TERM"] = translate_semester_inv(stripped_term)
return row_dict


def TOKEN(self, items):
"""
A token simply represents itself.
Expand Down
12 changes: 8 additions & 4 deletions backend/review/management/commands/iscimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def assert_semesters_not_current(semesters):
f"Did you forget to update the SEMESTER option in the Django admin console?"
)


class Command(BaseCommand):
help = """
Import course review data from the zip of mysqldump files that we get from ISC every semester.
Expand Down Expand Up @@ -159,7 +160,7 @@ def handle(self, *args, **kwargs):
import_all = kwargs["import_all"]
s3_bucket = kwargs["s3_bucket"]
is_zip_file = kwargs["zip"] or s3_bucket is not None
summary_file = kwargs["summary_file"] # either summary table or summary hist table
summary_file = kwargs["summary_file"] # either summary table or summary hist table
import_details = kwargs["import_details"]
import_descriptions = kwargs["import_descriptions"]
show_progress_bar = kwargs["show_progress_bar"]
Expand Down Expand Up @@ -220,7 +221,7 @@ def handle(self, *args, **kwargs):

for semester in semesters:
print(f"Loading {semester}...")
with transaction.atomic(): # Only commit changes if all imports for the semester succeed
with transaction.atomic(): # Commit changes if all imports for the semester succeed
to_delete = Review.objects.filter(section__course__semester=semester)
delete_count = to_delete.count()
if delete_count > 0:
Expand All @@ -234,12 +235,15 @@ def handle(self, *args, **kwargs):
return 0

print(
f"Deleting {delete_count} existing reviews for {semester} from the database..."
f"Deleting {delete_count} existing reviews for {semester} "
"from the database..."
)
to_delete.delete()

print(f"Importing reviews for semester {semester}")
stats = import_summary_rows((r for r in summary_rows if r["TERM"] == semester), show_progress_bar)
stats = import_summary_rows(
(r for r in summary_rows if r["TERM"] == semester), show_progress_bar
)
print(stats)

gc.collect()
Expand Down
4 changes: 1 addition & 3 deletions backend/tests/review/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,7 @@ def test_semester_transformation(self):
(TERM) Values ('202230');
"""
parse = parse_row(query)
expected = {
"TERM": "2022C"
}
expected = {"TERM": "2022C"}
self.assertDictEqual(parse, expected)


Expand Down

0 comments on commit 19caff4

Please sign in to comment.