Skip to content
Snippets Groups Projects
Commit 46f42a15 authored by David Ormsbee's avatar David Ormsbee
Browse files

perf: reduce calls to get_course_by_id

CoursewareMeta alredy initializes self.course, so there's no need to
separately call get_course_by_id for various attributes. This was
resulting in separate modulestore fetches that would pull down the
structure document and re-do all the expensive top-level course queries
in modulestore.
parent 85dc8c8d
No related branches found
No related tags found
No related merge requests found
......@@ -162,8 +162,7 @@ class CoursewareMeta:
@property
def license(self):
course = get_course_by_id(self.course_key)
return course.license
return self.course.license
@property
def can_load_courseware(self) -> dict:
......@@ -226,9 +225,8 @@ class CoursewareMeta:
def user_has_passing_grade(self):
""" Returns a boolean on if the effective_user has a passing grade in the course """
if not self.effective_user.is_anonymous:
course = get_course_by_id(self.course_key)
user_grade = CourseGradeFactory().read(self.effective_user, course).percent
return user_grade >= course.lowest_passing_grade
user_grade = CourseGradeFactory().read(self.effective_user, self.course).percent
return user_grade >= self.course.lowest_passing_grade
return False
@property
......@@ -242,9 +240,8 @@ class CoursewareMeta:
Returns certificate data if the effective_user is enrolled.
Note: certificate data can be None depending on learner and/or course state.
"""
course = get_course_by_id(self.course_key)
if self.enrollment_object:
return get_cert_data(self.effective_user, course, self.enrollment_object.mode)
return get_cert_data(self.effective_user, self.course, self.enrollment_object.mode)
@property
def verify_identity_url(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment