From 4216eaf5c33e4fb21d36b3f6f0111fe870696500 Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Thu, 5 Nov 2015 21:34:55 -0500 Subject: [PATCH] change 'routing' for some reports which go to potentially backlogged queues --- lms/djangoapps/instructor_task/tasks.py | 8 ++++---- lms/djangoapps/instructor_task/tasks_helper.py | 12 +++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lms/djangoapps/instructor_task/tasks.py b/lms/djangoapps/instructor_task/tasks.py index 37f4b89aac08..2ef4aedb60bb 100644 --- a/lms/djangoapps/instructor_task/tasks.py +++ b/lms/djangoapps/instructor_task/tasks.py @@ -204,7 +204,7 @@ def calculate_students_features_csv(entry_id, xmodule_instance_args): return run_main_task(entry_id, task_fn, action_name) -@task(base=BaseInstructorTask, routing_key=settings.GRADES_DOWNLOAD_ROUTING_KEY) # pylint: disable=not-callable +@task(base=BaseInstructorTask) # pylint: disable=not-callable def enrollment_report_features_csv(entry_id, xmodule_instance_args): """ Compute student profile information for a course and upload the @@ -216,7 +216,7 @@ def enrollment_report_features_csv(entry_id, xmodule_instance_args): return run_main_task(entry_id, task_fn, action_name) -@task(base=BaseInstructorTask, routing_key=settings.GRADES_DOWNLOAD_ROUTING_KEY) # pylint: disable=not-callable +@task(base=BaseInstructorTask) # pylint: disable=not-callable def exec_summary_report_csv(entry_id, xmodule_instance_args): """ Compute executive summary report for a course and upload the @@ -228,7 +228,7 @@ def exec_summary_report_csv(entry_id, xmodule_instance_args): return run_main_task(entry_id, task_fn, action_name) -@task(base=BaseInstructorTask, routing_key=settings.GRADES_DOWNLOAD_ROUTING_KEY) # pylint: disable=not-callable +@task(base=BaseInstructorTask) # pylint: disable=not-callable def course_survey_report_csv(entry_id, xmodule_instance_args): """ Compute the survey report for a course and upload the @@ -240,7 +240,7 @@ def course_survey_report_csv(entry_id, xmodule_instance_args): return run_main_task(entry_id, task_fn, action_name) -@task(base=BaseInstructorTask, routing_key=settings.GRADES_DOWNLOAD_ROUTING_KEY) # pylint: disable=not-callable +@task(base=BaseInstructorTask) # pylint: disable=not-callable def proctored_exam_results_csv(entry_id, xmodule_instance_args): """ Compute proctored exam results report for a course and upload the diff --git a/lms/djangoapps/instructor_task/tasks_helper.py b/lms/djangoapps/instructor_task/tasks_helper.py index c823abd22e0a..3f095c6691ba 100644 --- a/lms/djangoapps/instructor_task/tasks_helper.py +++ b/lms/djangoapps/instructor_task/tasks_helper.py @@ -1327,12 +1327,15 @@ def upload_course_survey_report(_xmodule_instance_args, _entry_id, course_id, _t survey_fields.sort() user_survey_answers = OrderedDict() - survey_answers_for_course = SurveyAnswer.objects.filter(course_key=course_id) + survey_answers_for_course = SurveyAnswer.objects.filter(course_key=course_id).select_related('user') for survey_field_record in survey_answers_for_course: user_id = survey_field_record.user.id if user_id not in user_survey_answers.keys(): - user_survey_answers[user_id] = {} + user_survey_answers[user_id] = { + 'username': survey_field_record.user.username, + 'email': survey_field_record.user.email + } user_survey_answers[user_id][survey_field_record.field_name] = survey_field_record.field_value @@ -1343,9 +1346,8 @@ def upload_course_survey_report(_xmodule_instance_args, _entry_id, course_id, _t for user_id in user_survey_answers.keys(): row = [] row.append(user_id) - user_obj = User.objects.get(id=user_id) - row.append(user_obj.username) - row.append(user_obj.email) + row.append(user_survey_answers[user_id].get('username', '')) + row.append(user_survey_answers[user_id].get('email', '')) for survey_field in survey_fields: row.append(user_survey_answers[user_id].get(survey_field, '')) csv_rows.append(row)