Performance optimizations and cache to keep the bookmarks info updated.
The cache uses the bookmarks.XBlockCache model. TNL-1945
This commit is contained in:
committed by
muzaffaryousaf
parent
dbb5232681
commit
4304c66c54
@@ -6,7 +6,7 @@ from .exceptions import (ItemNotFoundError, NoPathToItem)
|
||||
LOGGER = getLogger(__name__)
|
||||
|
||||
|
||||
def path_to_location(modulestore, usage_key):
|
||||
def path_to_location(modulestore, usage_key, full_path=False):
|
||||
'''
|
||||
Try to find a course_id/chapter/section[/position] path to location in
|
||||
modulestore. The courseware insists that the first level in the course is
|
||||
@@ -15,6 +15,7 @@ def path_to_location(modulestore, usage_key):
|
||||
Args:
|
||||
modulestore: which store holds the relevant objects
|
||||
usage_key: :class:`UsageKey` the id of the location to which to generate the path
|
||||
full_path: :class:`Bool` if True, return the full path to location. Default is False.
|
||||
|
||||
Raises
|
||||
ItemNotFoundError if the location doesn't exist.
|
||||
@@ -81,6 +82,9 @@ def path_to_location(modulestore, usage_key):
|
||||
if path is None:
|
||||
raise NoPathToItem(usage_key)
|
||||
|
||||
if full_path:
|
||||
return path
|
||||
|
||||
n = len(path)
|
||||
course_id = path[0].course_key
|
||||
# pull out the location names
|
||||
|
||||
@@ -18,10 +18,12 @@ from openedx.core.lib.tempdir import mkdtemp_clean
|
||||
|
||||
from xmodule.contentstore.django import _CONTENTSTORE
|
||||
from xmodule.modulestore import ModuleStoreEnum
|
||||
from xmodule.modulestore.django import modulestore, clear_existing_modulestores
|
||||
from xmodule.modulestore.django import modulestore, clear_existing_modulestores, SignalHandler
|
||||
from xmodule.modulestore.tests.mongo_connection import MONGO_PORT_NUM, MONGO_HOST
|
||||
from xmodule.modulestore.tests.factories import XMODULE_FACTORY_LOCK
|
||||
|
||||
from openedx.core.djangoapps.bookmarks.signals import trigger_update_xblocks_cache_task
|
||||
|
||||
|
||||
class StoreConstructors(object):
|
||||
"""Enumeration of store constructor types."""
|
||||
@@ -405,6 +407,8 @@ class ModuleStoreTestCase(TestCase):
|
||||
|
||||
super(ModuleStoreTestCase, self).setUp()
|
||||
|
||||
SignalHandler.course_published.disconnect(trigger_update_xblocks_cache_task)
|
||||
|
||||
self.store = modulestore()
|
||||
|
||||
uname = 'testuser'
|
||||
|
||||
Reference in New Issue
Block a user