Improve: add data extraction management command - #440
Conversation
| 'lms.djangoapps.student_dashboard', | ||
|
|
||
| # Data extraction App | ||
| 'openedx.features.database_extract', |
| @@ -0,0 +1,5 @@ | |||
| from django.contrib import admin | |||
| from .models import TargetCourse | |||
| from django.contrib import admin | ||
| from .models import TargetCourse | ||
|
|
||
| admin.site.register(TargetCourse) |
There was a problem hiding this comment.
Model name should be improved. You should delete all migrations and recreate after updating the name of model
There was a problem hiding this comment.
name Improved. Now is CourseDataExtraction
| def get_file_url(answer): | ||
| try: | ||
| return ora_file_upload_api.get_download_url(answer.file_key) | ||
| except: |
There was a problem hiding this comment.
is it possible to create some custom exception for this ?
| 'modified': course_structure.modified.__str__(), | ||
| 'course_id': course_structure.course_id.to_deprecated_string(), | ||
| 'structure_json': course_structure.structure_json, | ||
| 'discussion_id_map_json': course_structure.discussion_id_map_json, |
There was a problem hiding this comment.
is this map contain the id of course related NodeBB discussion ?
There was a problem hiding this comment.
No. this is something that is built in. I'm not sure what this is. Probably the discussion_id of default Ruby/Sinatra app that edx uses.
|
|
||
| user_community_data = json.loads(response._content)['payload'] | ||
|
|
||
| demo_data = { |
There was a problem hiding this comment.
i think variable name should be updated
| 'postcount': user_community_data['postcount'], | ||
| } | ||
|
|
||
| anon_user_id = AnonymousUserId.objects.get( |
There was a problem hiding this comment.
you should get all users anonymous user_ids in a single query and convert them to a map. Then inside loop you can reuse that map instead of making a query for each loop iteration.
| 'done': module.done, | ||
| 'created': module.created.__str__(), | ||
| 'modified': module.modified.__str__(), | ||
| } for module in StudentModule.objects.filter(student_id=profile.user.id)], |
There was a problem hiding this comment.
are you sure this loop will skip all irrelevant records in StudentModule table like type="sequential" ? i think this will get some extra data that we don't need. Also this code should also be spitted using functions.
There was a problem hiding this comment.
I think they don't mind if we deliver this data as well.
| old_name='email_list', | ||
| new_name='emails', | ||
| ), | ||
| ] |
There was a problem hiding this comment.
delete all existing migrations and create only one migration as all db related things are final now.
| emails = models.TextField() | ||
|
|
||
| def __unicode__(self): | ||
| return '{}'.format(self.course_id) No newline at end of file |
There was a problem hiding this comment.
enter new line at end of each file.
No description provided.