From f57b02c19948a0220e65976ddae92f0d719fc918 Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Fri, 2 Aug 2013 22:19:59 -0400 Subject: [PATCH] add a metadata cache and re-compute ignore when deleting a course to speed up the whole thing as well as squelching warnings in the console output --- .../management/commands/delete_course.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/cms/djangoapps/contentstore/management/commands/delete_course.py b/cms/djangoapps/contentstore/management/commands/delete_course.py index 5aafe9f8a6..4d8c4eda55 100644 --- a/cms/djangoapps/contentstore/management/commands/delete_course.py +++ b/cms/djangoapps/contentstore/management/commands/delete_course.py @@ -9,12 +9,14 @@ from xmodule.course_module import CourseDescriptor from .prompt import query_yes_no from auth.authz import _delete_course_group +from request_cache.middleware import RequestCache +from django.core.cache import get_cache # # To run from command line: rake cms:delete_course LOC=MITx/111/Foo1 # - +CACHE = get_cache('mongo_metadata_inheritance') class Command(BaseCommand): help = '''Delete a MongoDB backed course''' @@ -22,7 +24,7 @@ class Command(BaseCommand): if len(args) != 1 and len(args) != 2: raise CommandError("delete_course requires one or more arguments: |commit|") - loc_str = args[0] + course_id = args[0] commit = False if len(args) == 2: @@ -34,9 +36,14 @@ class Command(BaseCommand): ms = modulestore('direct') cs = contentstore() - if query_yes_no("Deleting course {0}. Confirm?".format(loc_str), default="no"): + ms.metadata_inheritance_cache_subsystem = CACHE + ms.request_cache = RequestCache.get_request_cache() + org, course_num, run = course_id.split("/") + ms.ignore_write_events_on_courses.append('{0}/{1}'.format(org, course_num)) + + if query_yes_no("Deleting course {0}. Confirm?".format(course_id), default="no"): if query_yes_no("Are you sure. This action cannot be undone!", default="no"): - loc = CourseDescriptor.id_to_location(loc_str) + loc = CourseDescriptor.id_to_location(course_id) if delete_course(ms, cs, loc, commit): print 'removing User permissions from course....' # in the django layer, we need to remove all the user permissions groups associated with this course