platform-plugin-aspects 0.9.7__tar.gz → 0.11.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/CHANGELOG.rst +16 -0
- {platform_plugin_aspects-0.9.7/platform_plugin_aspects.egg-info → platform_plugin_aspects-0.11.0}/PKG-INFO +19 -1
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/README.rst +2 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/__init__.py +1 -1
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/apps.py +12 -1
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/settings/common.py +13 -0
- platform_plugin_aspects-0.11.0/platform_plugin_aspects/signals.py +247 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/sinks/__init__.py +2 -0
- platform_plugin_aspects-0.11.0/platform_plugin_aspects/sinks/course_enrollment_sink.py +20 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/sinks/serializers.py +91 -0
- platform_plugin_aspects-0.11.0/platform_plugin_aspects/sinks/tag_sink.py +47 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/tasks.py +3 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/utils.py +11 -24
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0/platform_plugin_aspects.egg-info}/PKG-INFO +19 -1
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects.egg-info/SOURCES.txt +2 -0
- platform_plugin_aspects-0.9.7/platform_plugin_aspects/signals.py +0 -119
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/LICENSE +0 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/MANIFEST.in +0 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/extensions/__init__.py +0 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/extensions/filters.py +0 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/management/__init__.py +0 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/management/commands/__init__.py +0 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/management/commands/dump_data_to_clickhouse.py +0 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/management/commands/load_test_tracking_events.py +0 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/management/commands/monitor_load_test_tracking.py +0 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/settings/__init__.py +0 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/settings/production.py +0 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/sinks/base_sink.py +0 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/sinks/course_overview_sink.py +0 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/sinks/external_id_sink.py +0 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/sinks/user_profile_sink.py +0 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/sinks/user_retire_sink.py +0 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/static/css/superset.css +0 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/static/html/superset.html +0 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/static/html/superset_student.html +0 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/static/js/embed_dashboard.js +0 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/static/js/install_required.js +0 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/static/js/superset.js +0 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/templates/instructor_dashboard/aspects.html +0 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/urls.py +0 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/views.py +0 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/waffle.py +0 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/xblock.py +0 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects.egg-info/dependency_links.txt +0 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects.egg-info/entry_points.txt +0 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects.egg-info/not-zip-safe +0 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects.egg-info/requires.txt +0 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects.egg-info/top_level.txt +0 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/requirements/base.in +0 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/requirements/constraints.txt +0 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/setup.cfg +0 -0
- {platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/setup.py +0 -0
|
@@ -14,6 +14,22 @@ Change Log
|
|
|
14
14
|
Unreleased
|
|
15
15
|
**********
|
|
16
16
|
|
|
17
|
+
0.11.0 - 2024-09-04
|
|
18
|
+
*******************
|
|
19
|
+
|
|
20
|
+
Added
|
|
21
|
+
=====
|
|
22
|
+
|
|
23
|
+
* A sink for the object tags, tags and taxonomy.
|
|
24
|
+
|
|
25
|
+
0.10.0 - 2024-06-17
|
|
26
|
+
*******************
|
|
27
|
+
|
|
28
|
+
Added
|
|
29
|
+
=====
|
|
30
|
+
|
|
31
|
+
* A sink for the course enrollment model.
|
|
32
|
+
|
|
17
33
|
0.9.7 - 2024-06-14
|
|
18
34
|
******************
|
|
19
35
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: platform-plugin-aspects
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.11.0
|
|
4
4
|
Summary: Aspects plugins for edx-platform
|
|
5
5
|
Home-page: https://github.com/openedx/platform-plugin-aspects
|
|
6
6
|
Author: Open edX Project
|
|
@@ -58,6 +58,8 @@ Available Sinks
|
|
|
58
58
|
model and stores the user profile data in ClickHouse.
|
|
59
59
|
- `UserRetirementSink` - Listen for the `USER_RETIRE_LMS_MISC` Django signal and
|
|
60
60
|
remove the user PII information from ClickHouse.
|
|
61
|
+
- `CourseEnrollmentSink` - Listen for the `ENROLL_STATUS_CHANGE` event and stores
|
|
62
|
+
the course enrollment data.
|
|
61
63
|
|
|
62
64
|
Commands
|
|
63
65
|
========
|
|
@@ -276,6 +278,22 @@ Change Log
|
|
|
276
278
|
Unreleased
|
|
277
279
|
**********
|
|
278
280
|
|
|
281
|
+
0.11.0 - 2024-09-04
|
|
282
|
+
*******************
|
|
283
|
+
|
|
284
|
+
Added
|
|
285
|
+
=====
|
|
286
|
+
|
|
287
|
+
* A sink for the object tags, tags and taxonomy.
|
|
288
|
+
|
|
289
|
+
0.10.0 - 2024-06-17
|
|
290
|
+
*******************
|
|
291
|
+
|
|
292
|
+
Added
|
|
293
|
+
=====
|
|
294
|
+
|
|
295
|
+
* A sink for the course enrollment model.
|
|
296
|
+
|
|
279
297
|
0.9.7 - 2024-06-14
|
|
280
298
|
******************
|
|
281
299
|
|
|
@@ -23,6 +23,8 @@ Available Sinks
|
|
|
23
23
|
model and stores the user profile data in ClickHouse.
|
|
24
24
|
- `UserRetirementSink` - Listen for the `USER_RETIRE_LMS_MISC` Django signal and
|
|
25
25
|
remove the user PII information from ClickHouse.
|
|
26
|
+
- `CourseEnrollmentSink` - Listen for the `ENROLL_STATUS_CHANGE` event and stores
|
|
27
|
+
the course enrollment data.
|
|
26
28
|
|
|
27
29
|
Commands
|
|
28
30
|
========
|
{platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/apps.py
RENAMED
|
@@ -49,7 +49,18 @@ class PlatformPluginAspectsConfig(AppConfig):
|
|
|
49
49
|
PluginSignals.SIGNAL_PATH: "xmodule.modulestore.django.COURSE_PUBLISHED",
|
|
50
50
|
}
|
|
51
51
|
],
|
|
52
|
-
}
|
|
52
|
+
},
|
|
53
|
+
"lms.djangoapp": {
|
|
54
|
+
# List of all plugin Signal receivers for this app and project type.
|
|
55
|
+
PluginSignals.RECEIVERS: [
|
|
56
|
+
{
|
|
57
|
+
# The name of the app's signal receiver function.
|
|
58
|
+
PluginSignals.RECEIVER_FUNC_NAME: "receive_course_enrollment_changed",
|
|
59
|
+
# The full path to the module where the signal is defined.
|
|
60
|
+
PluginSignals.SIGNAL_PATH: "common.djangoapps.student.signals.signals.ENROLL_STATUS_CHANGE",
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
},
|
|
53
64
|
},
|
|
54
65
|
}
|
|
55
66
|
|
|
@@ -82,6 +82,10 @@ def plugin_settings(settings):
|
|
|
82
82
|
"module": "openedx.core.djangoapps.external_user_ids.models",
|
|
83
83
|
"model": "ExternalId",
|
|
84
84
|
},
|
|
85
|
+
"course_enrollment": {
|
|
86
|
+
"module": "common.djangoapps.student.models",
|
|
87
|
+
"model": "CourseEnrollment",
|
|
88
|
+
},
|
|
85
89
|
"custom_course_edx": {
|
|
86
90
|
"module": "lms.djangoapps.ccx.models",
|
|
87
91
|
"model": "CustomCourseForEdX",
|
|
@@ -90,4 +94,13 @@ def plugin_settings(settings):
|
|
|
90
94
|
"module": "openedx.core.djangoapps.user_api.models",
|
|
91
95
|
"model": "UserPreference",
|
|
92
96
|
},
|
|
97
|
+
"tag": {"module": "openedx_tagging.core.tagging.models", "model": "Tag"},
|
|
98
|
+
"taxonomy": {
|
|
99
|
+
"module": "openedx_tagging.core.tagging.models",
|
|
100
|
+
"model": "Taxonomy",
|
|
101
|
+
},
|
|
102
|
+
"object_tag": {
|
|
103
|
+
"module": "openedx_tagging.core.tagging.models",
|
|
104
|
+
"model": "ObjectTag",
|
|
105
|
+
},
|
|
93
106
|
}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Signal handler functions, mapped to specific signals in apps.py.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from django.db import transaction
|
|
6
|
+
from django.db.models.signals import post_delete, post_save
|
|
7
|
+
from django.dispatch import Signal, receiver
|
|
8
|
+
|
|
9
|
+
from platform_plugin_aspects.sinks import (
|
|
10
|
+
CourseEnrollmentSink,
|
|
11
|
+
ExternalIdSink,
|
|
12
|
+
ObjectTagSink,
|
|
13
|
+
TagSink,
|
|
14
|
+
TaxonomySink,
|
|
15
|
+
UserProfileSink,
|
|
16
|
+
UserRetirementSink,
|
|
17
|
+
)
|
|
18
|
+
from platform_plugin_aspects.utils import get_model
|
|
19
|
+
|
|
20
|
+
try:
|
|
21
|
+
from openedx.core.djangoapps.user_api.accounts.signals import USER_RETIRE_LMS_MISC
|
|
22
|
+
except ImportError:
|
|
23
|
+
# Tests don't have the platform installed
|
|
24
|
+
USER_RETIRE_LMS_MISC = Signal()
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def receive_course_publish( # pylint: disable=unused-argument # pragma: no cover
|
|
28
|
+
sender, course_key, **kwargs
|
|
29
|
+
):
|
|
30
|
+
"""
|
|
31
|
+
Receives COURSE_PUBLISHED signal and queues the dump job.
|
|
32
|
+
"""
|
|
33
|
+
# import here, because signal is registered at startup, but items in tasks are not yet able to be loaded
|
|
34
|
+
from platform_plugin_aspects.tasks import ( # pylint: disable=import-outside-toplevel
|
|
35
|
+
dump_course_to_clickhouse,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
dump_course_to_clickhouse.delay(str(course_key))
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def receive_course_enrollment_changed( # pylint: disable=unused-argument # pragma: no cover
|
|
42
|
+
sender, **kwargs
|
|
43
|
+
):
|
|
44
|
+
"""
|
|
45
|
+
Receives ENROLL_STATUS_CHANGE signal and queues the dump job.
|
|
46
|
+
"""
|
|
47
|
+
from platform_plugin_aspects.tasks import ( # pylint: disable=import-outside-toplevel
|
|
48
|
+
dump_data_to_clickhouse,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
user = kwargs.get("user")
|
|
52
|
+
course_id = kwargs.get("course_id")
|
|
53
|
+
|
|
54
|
+
CourseEnrollment = get_model("course_enrollment")
|
|
55
|
+
instance = CourseEnrollment.objects.get(user=user, course_id=course_id)
|
|
56
|
+
|
|
57
|
+
sink = CourseEnrollmentSink(None, None)
|
|
58
|
+
|
|
59
|
+
dump_data_to_clickhouse.delay(
|
|
60
|
+
sink_module=sink.__module__,
|
|
61
|
+
sink_name=sink.__class__.__name__,
|
|
62
|
+
object_id=instance.id,
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def on_user_profile_updated(instance):
|
|
67
|
+
"""
|
|
68
|
+
Queues the UserProfile dump job when the parent transaction is committed.
|
|
69
|
+
"""
|
|
70
|
+
# import here, because signal is registered at startup, but items in tasks are not yet able to be loaded
|
|
71
|
+
from platform_plugin_aspects.tasks import ( # pylint: disable=import-outside-toplevel
|
|
72
|
+
dump_data_to_clickhouse,
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
sink = UserProfileSink(None, None)
|
|
76
|
+
dump_data_to_clickhouse.delay(
|
|
77
|
+
sink_module=sink.__module__,
|
|
78
|
+
sink_name=sink.__class__.__name__,
|
|
79
|
+
object_id=str(instance.id),
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def on_user_profile_updated_txn(**kwargs):
|
|
84
|
+
"""
|
|
85
|
+
Handle user_profile saves in the middle of a transaction.
|
|
86
|
+
|
|
87
|
+
If this gets fired before the transaction commits, the task may try to
|
|
88
|
+
query an id that doesn't exist yet and throw an error. This should postpone
|
|
89
|
+
queuing the Celery task until after the transaction is committed.
|
|
90
|
+
"""
|
|
91
|
+
transaction.on_commit(
|
|
92
|
+
lambda: on_user_profile_updated(kwargs["instance"])
|
|
93
|
+
) # pragma: no cover
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
# Connect the UserProfile.post_save signal handler only if we have a model to attach to.
|
|
97
|
+
# (prevents celery errors during tests)
|
|
98
|
+
_user_profile = get_model("user_profile")
|
|
99
|
+
if _user_profile:
|
|
100
|
+
post_save.connect(
|
|
101
|
+
on_user_profile_updated_txn, sender=_user_profile
|
|
102
|
+
) # pragma: no cover
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def on_externalid_saved( # pylint: disable=unused-argument # pragma: no cover
|
|
106
|
+
sender, instance, **kwargs
|
|
107
|
+
):
|
|
108
|
+
"""
|
|
109
|
+
Receives post save signal and queues the dump job.
|
|
110
|
+
"""
|
|
111
|
+
# import here, because signal is registered at startup, but items in tasks are not yet able to be loaded
|
|
112
|
+
from platform_plugin_aspects.tasks import ( # pylint: disable=import-outside-toplevel
|
|
113
|
+
dump_data_to_clickhouse,
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
sink = ExternalIdSink(None, None)
|
|
117
|
+
dump_data_to_clickhouse.delay(
|
|
118
|
+
sink_module=sink.__module__,
|
|
119
|
+
sink_name=sink.__class__.__name__,
|
|
120
|
+
object_id=str(instance.id),
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
# Connect the ExternalId.post_save signal handler only if we have a model to attach to.
|
|
125
|
+
# (prevents celery errors during tests)
|
|
126
|
+
_external_id = get_model("external_id")
|
|
127
|
+
if _external_id:
|
|
128
|
+
post_save.connect(on_externalid_saved, sender=_external_id) # pragma: no cover
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
@receiver(USER_RETIRE_LMS_MISC)
|
|
132
|
+
def on_user_retirement( # pylint: disable=unused-argument # pragma: no cover
|
|
133
|
+
sender, user, **kwargs
|
|
134
|
+
):
|
|
135
|
+
"""
|
|
136
|
+
Receives a user retirement signal and queues the retire_user job.
|
|
137
|
+
"""
|
|
138
|
+
# import here, because signal is registered at startup, but items in tasks are not yet able to be loaded
|
|
139
|
+
from platform_plugin_aspects.tasks import ( # pylint: disable=import-outside-toplevel
|
|
140
|
+
dump_data_to_clickhouse,
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
sink = UserRetirementSink(None, None)
|
|
144
|
+
dump_data_to_clickhouse.delay(
|
|
145
|
+
sink_module=sink.__module__,
|
|
146
|
+
sink_name=sink.__class__.__name__,
|
|
147
|
+
object_id=str(user.id),
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def on_tag_saved( # pylint: disable=unused-argument # pragma: no cover
|
|
152
|
+
sender, instance, **kwargs
|
|
153
|
+
):
|
|
154
|
+
"""
|
|
155
|
+
Receives post save signal and queues the dump job.
|
|
156
|
+
"""
|
|
157
|
+
# import here, because signal is registered at startup, but items in tasks are not yet able to be loaded
|
|
158
|
+
from platform_plugin_aspects.tasks import ( # pylint: disable=import-outside-toplevel
|
|
159
|
+
dump_data_to_clickhouse,
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
sink = TagSink(None, None)
|
|
163
|
+
dump_data_to_clickhouse.delay(
|
|
164
|
+
sink_module=sink.__module__,
|
|
165
|
+
sink_name=sink.__class__.__name__,
|
|
166
|
+
object_id=str(instance.id),
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
# Connect the ExternalId.post_save signal handler only if we have a model to attach to.
|
|
171
|
+
# (prevents celery errors during tests)
|
|
172
|
+
_tag = get_model("tag")
|
|
173
|
+
if _tag:
|
|
174
|
+
post_save.connect(on_tag_saved, sender=_tag) # pragma: no cover
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def on_taxonomy_saved( # pylint: disable=unused-argument # pragma: no cover
|
|
178
|
+
sender, instance, **kwargs
|
|
179
|
+
):
|
|
180
|
+
"""
|
|
181
|
+
Receives post save signal and queues the dump job.
|
|
182
|
+
"""
|
|
183
|
+
# import here, because signal is registered at startup, but items in tasks are not yet able to be loaded
|
|
184
|
+
from platform_plugin_aspects.tasks import ( # pylint: disable=import-outside-toplevel
|
|
185
|
+
dump_data_to_clickhouse,
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
sink = TaxonomySink(None, None)
|
|
189
|
+
dump_data_to_clickhouse.delay(
|
|
190
|
+
sink_module=sink.__module__,
|
|
191
|
+
sink_name=sink.__class__.__name__,
|
|
192
|
+
object_id=str(instance.id),
|
|
193
|
+
)
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
# Connect the ExternalId.post_save signal handler only if we have a model to attach to.
|
|
197
|
+
# (prevents celery errors during tests)
|
|
198
|
+
_taxonomy = get_model("taxonomy")
|
|
199
|
+
if _taxonomy:
|
|
200
|
+
post_save.connect(on_taxonomy_saved, sender=_taxonomy) # pragma: no cover
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
def on_object_tag_saved(sender, instance, **kwargs): # pragma: no cover
|
|
204
|
+
"""
|
|
205
|
+
Receives post save signal and queues the dump job.
|
|
206
|
+
"""
|
|
207
|
+
# import here, because signal is registered at startup, but items in tasks are not yet able to be loaded
|
|
208
|
+
from platform_plugin_aspects.tasks import ( # pylint: disable=import-outside-toplevel
|
|
209
|
+
dump_data_to_clickhouse,
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
sink = ObjectTagSink(None, None)
|
|
213
|
+
dump_data_to_clickhouse.delay(
|
|
214
|
+
sink_module=sink.__module__,
|
|
215
|
+
sink_name=sink.__class__.__name__,
|
|
216
|
+
object_id=str(instance.id),
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
on_object_tag_deleted(sender, instance, **kwargs)
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
def on_object_tag_deleted( # pylint: disable=unused-argument # pragma: no cover
|
|
223
|
+
sender, instance, **kwargs
|
|
224
|
+
):
|
|
225
|
+
"""
|
|
226
|
+
Receives post save signal and queues the dump job.
|
|
227
|
+
"""
|
|
228
|
+
# import here, because signal is registered at startup, but items in tasks are not yet able to be loaded
|
|
229
|
+
from platform_plugin_aspects.tasks import ( # pylint: disable=import-outside-toplevel
|
|
230
|
+
dump_course_to_clickhouse,
|
|
231
|
+
)
|
|
232
|
+
|
|
233
|
+
CourseOverview = get_model("course_overviews")
|
|
234
|
+
if CourseOverview:
|
|
235
|
+
try:
|
|
236
|
+
CourseOverview.objects.get(id=instance.object_id)
|
|
237
|
+
dump_course_to_clickhouse.delay(instance.object_id)
|
|
238
|
+
except CourseOverview.DoesNotExist:
|
|
239
|
+
pass
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
# Connect the ExternalId.post_save signal handler only if we have a model to attach to.
|
|
243
|
+
# (prevents celery errors during tests)
|
|
244
|
+
_object_tag = get_model("object_tag")
|
|
245
|
+
if _object_tag: # pragma: no cover
|
|
246
|
+
post_save.connect(on_object_tag_saved, sender=_object_tag)
|
|
247
|
+
post_delete.connect(on_object_tag_deleted, sender=_object_tag)
|
|
@@ -3,7 +3,9 @@ This module contains the sinks for the platform plugin aspects.
|
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
5
|
from .base_sink import BaseSink, ModelBaseSink
|
|
6
|
+
from .course_enrollment_sink import CourseEnrollmentSink
|
|
6
7
|
from .course_overview_sink import CourseOverviewSink, XBlockSink
|
|
7
8
|
from .external_id_sink import ExternalIdSink
|
|
9
|
+
from .tag_sink import ObjectTagSink, TagSink, TaxonomySink
|
|
8
10
|
from .user_profile_sink import UserProfileSink
|
|
9
11
|
from .user_retire_sink import UserRetirementSink
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""User profile sink"""
|
|
2
|
+
|
|
3
|
+
from platform_plugin_aspects.sinks.base_sink import ModelBaseSink
|
|
4
|
+
from platform_plugin_aspects.sinks.serializers import CourseEnrollmentSerializer
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class CourseEnrollmentSink(ModelBaseSink): # pylint: disable=abstract-method
|
|
8
|
+
"""
|
|
9
|
+
Sink for user CourseEnrollment model
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
model = "course_enrollment"
|
|
13
|
+
unique_key = "id"
|
|
14
|
+
clickhouse_table_name = "course_enrollment"
|
|
15
|
+
timestamp_field = "time_last_dumped"
|
|
16
|
+
name = "Course Enrollment"
|
|
17
|
+
serializer_class = CourseEnrollmentSerializer
|
|
18
|
+
|
|
19
|
+
def get_queryset(self, start_pk=None):
|
|
20
|
+
return super().get_queryset(start_pk).select_related("user")
|
|
@@ -179,3 +179,94 @@ class CourseOverviewSerializer(BaseSinkSerializer, serializers.ModelSerializer):
|
|
|
179
179
|
def get_course_key(self, overview):
|
|
180
180
|
"""Return the course key as a string."""
|
|
181
181
|
return str(overview.id)
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
class CourseEnrollmentSerializer(BaseSinkSerializer, serializers.ModelSerializer):
|
|
185
|
+
"""Serializer for the Course Enrollment model."""
|
|
186
|
+
|
|
187
|
+
course_key = serializers.SerializerMethodField()
|
|
188
|
+
username = serializers.CharField(source="user.username")
|
|
189
|
+
|
|
190
|
+
class Meta:
|
|
191
|
+
"""Meta class for the CourseEnrollmentSerializer"""
|
|
192
|
+
|
|
193
|
+
model = get_model("course_enrollment")
|
|
194
|
+
fields = [
|
|
195
|
+
"id",
|
|
196
|
+
"course_key",
|
|
197
|
+
"created",
|
|
198
|
+
"is_active",
|
|
199
|
+
"mode",
|
|
200
|
+
"username",
|
|
201
|
+
"user_id",
|
|
202
|
+
"dump_id",
|
|
203
|
+
"time_last_dumped",
|
|
204
|
+
]
|
|
205
|
+
|
|
206
|
+
def get_course_key(self, obj):
|
|
207
|
+
"""Return the course key as a string."""
|
|
208
|
+
return str(obj.course_id)
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
class TagSerializer(BaseSinkSerializer, serializers.ModelSerializer):
|
|
212
|
+
"""Serializer for the Tag model."""
|
|
213
|
+
|
|
214
|
+
lineage = serializers.SerializerMethodField()
|
|
215
|
+
|
|
216
|
+
class Meta:
|
|
217
|
+
"""Meta class for the TagSerializer."""
|
|
218
|
+
|
|
219
|
+
model = get_model("tag")
|
|
220
|
+
fields = [
|
|
221
|
+
"id",
|
|
222
|
+
"taxonomy",
|
|
223
|
+
"parent",
|
|
224
|
+
"value",
|
|
225
|
+
"external_id",
|
|
226
|
+
"lineage",
|
|
227
|
+
"dump_id",
|
|
228
|
+
"time_last_dumped",
|
|
229
|
+
]
|
|
230
|
+
|
|
231
|
+
def get_lineage(self, instance):
|
|
232
|
+
return json.dumps(instance.get_lineage())
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
class ObjectTagSerializer(BaseSinkSerializer, serializers.ModelSerializer):
|
|
236
|
+
"""Serializer for the ObjectTag model."""
|
|
237
|
+
|
|
238
|
+
lineage = serializers.SerializerMethodField()
|
|
239
|
+
|
|
240
|
+
class Meta:
|
|
241
|
+
"""Meta class for the ObjectTagSerializer"""
|
|
242
|
+
|
|
243
|
+
model = get_model("object_tag")
|
|
244
|
+
fields = [
|
|
245
|
+
"id",
|
|
246
|
+
"object_id",
|
|
247
|
+
"taxonomy",
|
|
248
|
+
"tag",
|
|
249
|
+
"_value",
|
|
250
|
+
"_export_id",
|
|
251
|
+
"lineage",
|
|
252
|
+
"dump_id",
|
|
253
|
+
"time_last_dumped",
|
|
254
|
+
]
|
|
255
|
+
|
|
256
|
+
def get_lineage(self, instance):
|
|
257
|
+
return json.dumps(instance.get_lineage())
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
class TaxonomySerializer(BaseSinkSerializer, serializers.ModelSerializer):
|
|
261
|
+
"""Serializer for the Taxonomy model."""
|
|
262
|
+
|
|
263
|
+
class Meta:
|
|
264
|
+
"""Meta class for the TaxonomySerializer."""
|
|
265
|
+
|
|
266
|
+
model = get_model("taxonomy")
|
|
267
|
+
fields = [
|
|
268
|
+
"id",
|
|
269
|
+
"name",
|
|
270
|
+
"dump_id",
|
|
271
|
+
"time_last_dumped",
|
|
272
|
+
]
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""Tag sink"""
|
|
2
|
+
|
|
3
|
+
from platform_plugin_aspects.sinks.base_sink import ModelBaseSink
|
|
4
|
+
from platform_plugin_aspects.sinks.serializers import (
|
|
5
|
+
ObjectTagSerializer,
|
|
6
|
+
TagSerializer,
|
|
7
|
+
TaxonomySerializer,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class TagSink(ModelBaseSink): # pylint: disable=abstract-method
|
|
12
|
+
"""
|
|
13
|
+
Sink for content tags
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
model = "tag"
|
|
17
|
+
unique_key = "id"
|
|
18
|
+
clickhouse_table_name = "tag"
|
|
19
|
+
timestamp_field = "time_last_dumped"
|
|
20
|
+
name = "Tag"
|
|
21
|
+
serializer_class = TagSerializer
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class TaxonomySink(ModelBaseSink): # pylint: disable=abstract-method
|
|
25
|
+
"""
|
|
26
|
+
Sink for content taxonomy
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
model = "taxonomy"
|
|
30
|
+
unique_key = "id"
|
|
31
|
+
clickhouse_table_name = "taxonomy"
|
|
32
|
+
timestamp_field = "time_last_dumped"
|
|
33
|
+
name = "Taxonomy"
|
|
34
|
+
serializer_class = TaxonomySerializer
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class ObjectTagSink(ModelBaseSink): # pylint: disable=abstract-method
|
|
38
|
+
"""
|
|
39
|
+
Sink for tagged objects
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
model = "object_tag"
|
|
43
|
+
unique_key = "id"
|
|
44
|
+
clickhouse_table_name = "object_tag"
|
|
45
|
+
timestamp_field = "time_last_dumped"
|
|
46
|
+
name = "ObjectTag"
|
|
47
|
+
serializer_class = ObjectTagSerializer
|
{platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/utils.py
RENAMED
|
@@ -294,31 +294,18 @@ def _get_object_tags(usage_key): # pragma: no cover
|
|
|
294
294
|
return {}
|
|
295
295
|
|
|
296
296
|
|
|
297
|
-
def get_tags_for_block(usage_key) ->
|
|
297
|
+
def get_tags_for_block(usage_key) -> set:
|
|
298
298
|
"""
|
|
299
299
|
Return all the tags (and their parent tags) applied to the given block.
|
|
300
300
|
|
|
301
|
-
Returns a
|
|
301
|
+
Returns a set of tag id: [1, 2, 3]
|
|
302
302
|
"""
|
|
303
|
-
|
|
304
|
-
serialized_tags =
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
implicit_tag = implicit_tag.parent
|
|
313
|
-
|
|
314
|
-
return serialized_tags
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
def _add_tag(tag, serialized_tags):
|
|
318
|
-
"""
|
|
319
|
-
Add a tag to our serialized list of tags.
|
|
320
|
-
"""
|
|
321
|
-
if tag.taxonomy.name not in serialized_tags:
|
|
322
|
-
serialized_tags[tag.taxonomy.name] = [tag.value]
|
|
323
|
-
else:
|
|
324
|
-
serialized_tags[tag.taxonomy.name].append(tag.value)
|
|
303
|
+
object_tags = _get_object_tags(usage_key)
|
|
304
|
+
serialized_tags = set()
|
|
305
|
+
for object_tag in object_tags:
|
|
306
|
+
tag = object_tag.tag
|
|
307
|
+
while tag:
|
|
308
|
+
serialized_tags.add(tag.id)
|
|
309
|
+
tag = tag.parent
|
|
310
|
+
|
|
311
|
+
return list(serialized_tags)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: platform-plugin-aspects
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.11.0
|
|
4
4
|
Summary: Aspects plugins for edx-platform
|
|
5
5
|
Home-page: https://github.com/openedx/platform-plugin-aspects
|
|
6
6
|
Author: Open edX Project
|
|
@@ -58,6 +58,8 @@ Available Sinks
|
|
|
58
58
|
model and stores the user profile data in ClickHouse.
|
|
59
59
|
- `UserRetirementSink` - Listen for the `USER_RETIRE_LMS_MISC` Django signal and
|
|
60
60
|
remove the user PII information from ClickHouse.
|
|
61
|
+
- `CourseEnrollmentSink` - Listen for the `ENROLL_STATUS_CHANGE` event and stores
|
|
62
|
+
the course enrollment data.
|
|
61
63
|
|
|
62
64
|
Commands
|
|
63
65
|
========
|
|
@@ -276,6 +278,22 @@ Change Log
|
|
|
276
278
|
Unreleased
|
|
277
279
|
**********
|
|
278
280
|
|
|
281
|
+
0.11.0 - 2024-09-04
|
|
282
|
+
*******************
|
|
283
|
+
|
|
284
|
+
Added
|
|
285
|
+
=====
|
|
286
|
+
|
|
287
|
+
* A sink for the object tags, tags and taxonomy.
|
|
288
|
+
|
|
289
|
+
0.10.0 - 2024-06-17
|
|
290
|
+
*******************
|
|
291
|
+
|
|
292
|
+
Added
|
|
293
|
+
=====
|
|
294
|
+
|
|
295
|
+
* A sink for the course enrollment model.
|
|
296
|
+
|
|
279
297
|
0.9.7 - 2024-06-14
|
|
280
298
|
******************
|
|
281
299
|
|
|
@@ -32,9 +32,11 @@ platform_plugin_aspects/settings/common.py
|
|
|
32
32
|
platform_plugin_aspects/settings/production.py
|
|
33
33
|
platform_plugin_aspects/sinks/__init__.py
|
|
34
34
|
platform_plugin_aspects/sinks/base_sink.py
|
|
35
|
+
platform_plugin_aspects/sinks/course_enrollment_sink.py
|
|
35
36
|
platform_plugin_aspects/sinks/course_overview_sink.py
|
|
36
37
|
platform_plugin_aspects/sinks/external_id_sink.py
|
|
37
38
|
platform_plugin_aspects/sinks/serializers.py
|
|
39
|
+
platform_plugin_aspects/sinks/tag_sink.py
|
|
38
40
|
platform_plugin_aspects/sinks/user_profile_sink.py
|
|
39
41
|
platform_plugin_aspects/sinks/user_retire_sink.py
|
|
40
42
|
platform_plugin_aspects/static/css/superset.css
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Signal handler functions, mapped to specific signals in apps.py.
|
|
3
|
-
"""
|
|
4
|
-
|
|
5
|
-
from django.db import transaction
|
|
6
|
-
from django.db.models.signals import post_save
|
|
7
|
-
from django.dispatch import Signal, receiver
|
|
8
|
-
|
|
9
|
-
from platform_plugin_aspects.sinks import (
|
|
10
|
-
ExternalIdSink,
|
|
11
|
-
UserProfileSink,
|
|
12
|
-
UserRetirementSink,
|
|
13
|
-
)
|
|
14
|
-
from platform_plugin_aspects.utils import get_model
|
|
15
|
-
|
|
16
|
-
try:
|
|
17
|
-
from openedx.core.djangoapps.user_api.accounts.signals import USER_RETIRE_LMS_MISC
|
|
18
|
-
except ImportError:
|
|
19
|
-
# Tests don't have the platform installed
|
|
20
|
-
USER_RETIRE_LMS_MISC = Signal()
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def receive_course_publish( # pylint: disable=unused-argument # pragma: no cover
|
|
24
|
-
sender, course_key, **kwargs
|
|
25
|
-
):
|
|
26
|
-
"""
|
|
27
|
-
Receives COURSE_PUBLISHED signal and queues the dump job.
|
|
28
|
-
"""
|
|
29
|
-
# import here, because signal is registered at startup, but items in tasks are not yet able to be loaded
|
|
30
|
-
from platform_plugin_aspects.tasks import ( # pylint: disable=import-outside-toplevel
|
|
31
|
-
dump_course_to_clickhouse,
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
dump_course_to_clickhouse.delay(str(course_key))
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def on_user_profile_updated(instance):
|
|
38
|
-
"""
|
|
39
|
-
Queues the UserProfile dump job when the parent transaction is committed.
|
|
40
|
-
"""
|
|
41
|
-
# import here, because signal is registered at startup, but items in tasks are not yet able to be loaded
|
|
42
|
-
from platform_plugin_aspects.tasks import ( # pylint: disable=import-outside-toplevel
|
|
43
|
-
dump_data_to_clickhouse,
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
sink = UserProfileSink(None, None)
|
|
47
|
-
dump_data_to_clickhouse.delay(
|
|
48
|
-
sink_module=sink.__module__,
|
|
49
|
-
sink_name=sink.__class__.__name__,
|
|
50
|
-
object_id=str(instance.id),
|
|
51
|
-
)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
def on_user_profile_updated_txn(**kwargs):
|
|
55
|
-
"""
|
|
56
|
-
Handle user_profile saves in the middle of a transaction.
|
|
57
|
-
|
|
58
|
-
If this gets fired before the transaction commits, the task may try to
|
|
59
|
-
query an id that doesn't exist yet and throw an error. This should postpone
|
|
60
|
-
queuing the Celery task until after the transaction is committed.
|
|
61
|
-
"""
|
|
62
|
-
transaction.on_commit(
|
|
63
|
-
lambda: on_user_profile_updated(kwargs["instance"])
|
|
64
|
-
) # pragma: no cover
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
# Connect the UserProfile.post_save signal handler only if we have a model to attach to.
|
|
68
|
-
# (prevents celery errors during tests)
|
|
69
|
-
_user_profile = get_model("user_profile")
|
|
70
|
-
if _user_profile:
|
|
71
|
-
post_save.connect(
|
|
72
|
-
on_user_profile_updated_txn, sender=_user_profile
|
|
73
|
-
) # pragma: no cover
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
def on_externalid_saved( # pylint: disable=unused-argument # pragma: no cover
|
|
77
|
-
sender, instance, **kwargs
|
|
78
|
-
):
|
|
79
|
-
"""
|
|
80
|
-
Receives post save signal and queues the dump job.
|
|
81
|
-
"""
|
|
82
|
-
# import here, because signal is registered at startup, but items in tasks are not yet able to be loaded
|
|
83
|
-
from platform_plugin_aspects.tasks import ( # pylint: disable=import-outside-toplevel
|
|
84
|
-
dump_data_to_clickhouse,
|
|
85
|
-
)
|
|
86
|
-
|
|
87
|
-
sink = ExternalIdSink(None, None)
|
|
88
|
-
dump_data_to_clickhouse.delay(
|
|
89
|
-
sink_module=sink.__module__,
|
|
90
|
-
sink_name=sink.__class__.__name__,
|
|
91
|
-
object_id=str(instance.id),
|
|
92
|
-
)
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
# Connect the ExternalId.post_save signal handler only if we have a model to attach to.
|
|
96
|
-
# (prevents celery errors during tests)
|
|
97
|
-
_external_id = get_model("external_id")
|
|
98
|
-
if _external_id:
|
|
99
|
-
post_save.connect(on_externalid_saved, sender=_external_id) # pragma: no cover
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
@receiver(USER_RETIRE_LMS_MISC)
|
|
103
|
-
def on_user_retirement( # pylint: disable=unused-argument # pragma: no cover
|
|
104
|
-
sender, user, **kwargs
|
|
105
|
-
):
|
|
106
|
-
"""
|
|
107
|
-
Receives a user retirement signal and queues the retire_user job.
|
|
108
|
-
"""
|
|
109
|
-
# import here, because signal is registered at startup, but items in tasks are not yet able to be loaded
|
|
110
|
-
from platform_plugin_aspects.tasks import ( # pylint: disable=import-outside-toplevel
|
|
111
|
-
dump_data_to_clickhouse,
|
|
112
|
-
)
|
|
113
|
-
|
|
114
|
-
sink = UserRetirementSink(None, None)
|
|
115
|
-
dump_data_to_clickhouse.delay(
|
|
116
|
-
sink_module=sink.__module__,
|
|
117
|
-
sink_name=sink.__class__.__name__,
|
|
118
|
-
object_id=str(user.id),
|
|
119
|
-
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/urls.py
RENAMED
|
File without changes
|
{platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/views.py
RENAMED
|
File without changes
|
{platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/waffle.py
RENAMED
|
File without changes
|
{platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/platform_plugin_aspects/xblock.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{platform_plugin_aspects-0.9.7 → platform_plugin_aspects-0.11.0}/requirements/constraints.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|