From b178733d1283b04fcb0f22fb5d70d0540a5bf2fd Mon Sep 17 00:00:00 2001 From: Brian Mesick Date: Mon, 1 May 2023 09:40:53 -0400 Subject: [PATCH] feat: Add event listener for course publish Creates the edx-platform plugin plumbing, adds some new requirements, maps the appropriate Django Signal to push course structure to ClickHouse. --- event_sink_clickhouse/settings/common.py | 3 ++- event_sink_clickhouse/signals.py | 3 +-- event_sink_clickhouse/sinks/course_published.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/event_sink_clickhouse/settings/common.py b/event_sink_clickhouse/settings/common.py index a309da3..af40f90 100644 --- a/event_sink_clickhouse/settings/common.py +++ b/event_sink_clickhouse/settings/common.py @@ -9,7 +9,8 @@ def plugin_settings(settings): """ settings.EVENT_SINK_CLICKHOUSE_BACKEND_CONFIG = { # URL to a running ClickHouse server's HTTP interface. ex: https://foo.openedx.org:8443/ or - # http://foo.openedx.org:8123/ + # http://foo.openedx.org:8123/ . Note that we only support the ClickHouse HTTP interface + # to avoid pulling in more dependencies to the platrform than necessary. "url": "http://clickhouse:8123", "username": "changeme", "password": "changeme", diff --git a/event_sink_clickhouse/signals.py b/event_sink_clickhouse/signals.py index 360f975..f752120 100644 --- a/event_sink_clickhouse/signals.py +++ b/event_sink_clickhouse/signals.py @@ -10,5 +10,4 @@ def receive_course_publish(sender, course_key, **kwargs): # pylint: disable=unu # import here, because signal is registered at startup, but items in tasks are not yet able to be loaded from .tasks import dump_course_to_clickhouse # pylint: disable=import-outside-toplevel - course_key_str = str(course_key) - dump_course_to_clickhouse.delay(course_key_str) + dump_course_to_clickhouse.delay(str(course_key)) diff --git a/event_sink_clickhouse/sinks/course_published.py b/event_sink_clickhouse/sinks/course_published.py index 7a85e73..faa2067 100644 --- a/event_sink_clickhouse/sinks/course_published.py +++ b/event_sink_clickhouse/sinks/course_published.py @@ -100,8 +100,8 @@ def serialize_course(self, course_id): course_id: CourseKey of the course we want to serialize Returns: - nodes: a csv of nodes for the course - relationships: a csv of relationships between nodes + nodes: a list of dicts representing xblocks for the course + relationships: a list of dicts representing relationships between nodes """ # Import is placed here to avoid model import at project startup. from xmodule.modulestore.django import modulestore # pylint: disable=import-outside-toplevel,import-error