[TNL-5632] Optimize the single_thread view.
Firstly, we're now explicitly instructing the comments service to not return thread responses/comments if the request isn't AJAX. So, if you load the URL for a single discussion thread in your browser, this would be a non-AJAX call and we'll avoid loading the responses for the entire thread behind-the-scenes. Big win here for large threads. Next, we removed a redundant "get threads" call which was also happening behind-the-scenes. This call was redundant as the front-end JS also grabs the thread list when a topic is chosen, so we were making an extranenous call for no benefit. Poof, gone! Finally, we added some caching of database queries that are required to drive a lot of the permissions/cohorts machinery around discussion. This will have a minimal effect but introduced a cleaner way to apply general memoization at the per-request level which will let us further cache things as we identify them as issues.
This commit is contained in:
@@ -13,7 +13,7 @@ from django.utils.translation import ugettext as _
|
||||
|
||||
from courseware import courses
|
||||
from eventtracking import tracker
|
||||
from request_cache.middleware import RequestCache
|
||||
from request_cache.middleware import RequestCache, request_cached
|
||||
from student.models import get_user_by_username_or_email
|
||||
|
||||
from .models import (
|
||||
@@ -485,6 +485,7 @@ def set_course_cohort_settings(course_key, **kwargs):
|
||||
return course_cohort_settings
|
||||
|
||||
|
||||
@request_cached
|
||||
def get_course_cohort_settings(course_key):
|
||||
"""
|
||||
Return cohort settings for a course.
|
||||
|
||||
@@ -264,7 +264,7 @@ class TestCohorts(ModuleStoreTestCase):
|
||||
|
||||
@ddt.data(
|
||||
(True, 3),
|
||||
(False, 9),
|
||||
(False, 7),
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_get_cohort_sql_queries(self, use_cached, num_sql_queries):
|
||||
|
||||
Reference in New Issue
Block a user