diff --git a/cms/djangoapps/contentstore/signals/handlers.py b/cms/djangoapps/contentstore/signals/handlers.py index a67f958381..9945277a13 100644 --- a/cms/djangoapps/contentstore/signals/handlers.py +++ b/cms/djangoapps/contentstore/signals/handlers.py @@ -5,6 +5,7 @@ import logging from datetime import datetime from functools import wraps +from django.conf import settings from django.core.cache import cache from django.dispatch import receiver from pytz import UTC @@ -55,6 +56,9 @@ def listen_for_course_publish(sender, course_key, **kwargs): # pylint: disable= update_search_index, update_special_exams_and_publish ) + from cms.djangoapps.coursegraph.tasks import ( + dump_course_to_neo4j + ) # register special exams asynchronously course_key_str = str(course_key) @@ -64,6 +68,10 @@ def listen_for_course_publish(sender, course_key, **kwargs): # pylint: disable= # Push the course outline to learning_sequences asynchronously. update_outline_from_modulestore_task.delay(course_key_str) + if settings.COURSEGRAPH_DUMP_COURSE_ON_PUBLISH: + # Push the course out to CourseGraph asynchronously. + dump_course_to_neo4j.delay(course_key_str) + # Finally, call into the course search subsystem # to kick off an indexing action if CoursewareSearchIndexer.indexing_is_enabled() and CourseAboutSearchIndexer.indexing_is_enabled(): diff --git a/cms/envs/common.py b/cms/envs/common.py index 91cbbbc215..759f474d68 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -2253,6 +2253,16 @@ COURSEGRAPH_CONNECTION: dict = { "password": None, } +# .. toggle_name: COURSEGRAPH_DUMP_COURSE_ON_PUBLISH +# .. toggle_implementation: DjangoSetting +# .. toggle_creation_date: 2022-01-27 +# .. toggle_use_cases: open_edx +# .. toggle_default: False +# .. toggle_description: Whether, upon publish, a course should automatically +# be exported to Neo4j via the connection parameters specified in +# `COURSEGRAPH_CONNECTION`. +COURSEGRAPH_DUMP_COURSE_ON_PUBLISH: bool = False + ########## Settings for video transcript migration tasks ############ VIDEO_TRANSCRIPT_MIGRATIONS_JOB_QUEUE = DEFAULT_PRIORITY_QUEUE