Skip to content

Commit

Permalink
perf: use select_related to fetch types in CSVLoader (#4518)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali-D-Akbar authored Dec 19, 2024
1 parent 59b2e41 commit 771da54
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def ingest(self): # pylint: disable=too-many-statements
continue

course_key = self.get_course_key(org_key, row['number'])
course = Course.objects.filter_drafts(key=course_key, partner=self.partner).first()
course = Course.objects.filter_drafts(key=course_key, partner=self.partner).select_related('type').first()
is_course_created = False
is_course_run_created = False
course_run_restriction = (
Expand Down Expand Up @@ -201,8 +201,8 @@ def ingest(self): # pylint: disable=too-many-statements
self._register_ingestion_error(CSVIngestionErrors.COURSE_CREATE_ERROR, error_message)
continue

course = Course.everything.get(key=course_key, partner=self.partner)
course_run = CourseRun.everything.filter(course=course).first()
course = Course.everything.select_related('type').get(key=course_key, partner=self.partner)
course_run = CourseRun.everything.select_related('type').filter(course=course).first()
is_course_created = True
is_course_run_created = True

Expand Down

0 comments on commit 771da54

Please sign in to comment.