Enable model-caching of discussions ID mapping.
Doing modulestore lookups is expensive, so commit 695b036 created a
course_publish listener that would materialize the discussion ID to
XBlock usage key mapping into the CourseDiscussionSettings model.
However, the signal wasn't hooked up to the Studio process, so that
async task was never called. When hooking it up, I also discovered that
bok choy tests related to partitioning were failing because of a race
condition where multiple processes are overwriting the discussion
settings. To make sure this wasn't an issue, I moved the mapping to
its own table.
This is part of ARCH-111, and the overall Course Structures API
deprecation.
This commit is contained in:
@@ -25,9 +25,12 @@ class DiscussionConfig(AppConfig):
|
||||
}
|
||||
},
|
||||
PluginSettings.CONFIG: {
|
||||
ProjectType.CMS: {
|
||||
SettingsType.COMMON: {PluginSettings.RELATIVE_PATH: u'settings.common'},
|
||||
},
|
||||
ProjectType.LMS: {
|
||||
SettingsType.COMMON: {PluginSettings.RELATIVE_PATH: u'settings.common'},
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ from django.contrib.sites.models import Site
|
||||
|
||||
from celery_utils.logged_task import LoggedTask
|
||||
from django_comment_common.utils import set_course_discussion_settings
|
||||
from django_comment_common.models import DiscussionsIdMapping
|
||||
from edx_ace import ace
|
||||
from edx_ace.utils import date
|
||||
from edx_ace.recipient import Recipient
|
||||
@@ -48,7 +49,7 @@ def update_discussions_map(context):
|
||||
discussion_block.discussion_id: unicode(discussion_block.location)
|
||||
for discussion_block in discussion_blocks
|
||||
}
|
||||
set_course_discussion_settings(course_key, discussions_id_map=discussions_id_map)
|
||||
DiscussionsIdMapping.update_mapping(course_key, discussions_id_map)
|
||||
|
||||
|
||||
class ResponseNotification(BaseMessageType):
|
||||
|
||||
@@ -70,9 +70,6 @@ class CoursePublishHandlerTestCase(ModuleStoreTestCase):
|
||||
course_key_args = dict(org='org', course='number', run='run')
|
||||
course_key = self.store.make_course_key(**course_key_args)
|
||||
|
||||
with self.assertRaises(models.CourseDiscussionSettings.DoesNotExist):
|
||||
models.CourseDiscussionSettings.objects.get(course_id=course_key)
|
||||
|
||||
# create course
|
||||
course = CourseFactory(emit_signals=True, **course_key_args)
|
||||
self.assertEqual(course.id, course_key)
|
||||
@@ -92,5 +89,5 @@ class CoursePublishHandlerTestCase(ModuleStoreTestCase):
|
||||
"""
|
||||
Verifies the discussion ID map for the given course matches the expected value.
|
||||
"""
|
||||
discussion_settings = models.CourseDiscussionSettings.objects.get(course_id=course_key)
|
||||
self.assertDictEqual(discussion_settings.discussions_id_map, expected_map)
|
||||
mapping_entry = models.DiscussionsIdMapping.objects.get(course_id=course_key)
|
||||
self.assertDictEqual(mapping_entry.mapping, expected_map)
|
||||
|
||||
@@ -405,8 +405,8 @@ class ViewsQueryCountTestCase(
|
||||
return inner
|
||||
|
||||
@ddt.data(
|
||||
(ModuleStoreEnum.Type.mongo, 3, 3, 30),
|
||||
(ModuleStoreEnum.Type.split, 3, 11, 30),
|
||||
(ModuleStoreEnum.Type.mongo, 3, 4, 35),
|
||||
(ModuleStoreEnum.Type.split, 3, 13, 35),
|
||||
)
|
||||
@ddt.unpack
|
||||
@count_queries
|
||||
@@ -414,8 +414,8 @@ class ViewsQueryCountTestCase(
|
||||
self.create_thread_helper(mock_request)
|
||||
|
||||
@ddt.data(
|
||||
(ModuleStoreEnum.Type.mongo, 3, 2, 26),
|
||||
(ModuleStoreEnum.Type.split, 3, 8, 26),
|
||||
(ModuleStoreEnum.Type.mongo, 3, 3, 31),
|
||||
(ModuleStoreEnum.Type.split, 3, 10, 31),
|
||||
)
|
||||
@ddt.unpack
|
||||
@count_queries
|
||||
|
||||
Reference in New Issue
Block a user