P-106
This commit is contained in:
1 parent
7b130a4350
commit
4122cea735
1 file changed
+6
-2
@@ -202,8 +202,12 @@ class GetResults(APIView):
|
|||||||
if answers_employee:
|
if answers_employee:
|
||||||
employees = DictEmployee.objects.filter(id__in=answers_employee)
|
employees = DictEmployee.objects.filter(id__in=answers_employee)
|
||||||
employee_dict = {employee['id']: employee for employee in DictEmployeeSerializer(employees, many=True).data}
|
employee_dict = {employee['id']: employee for employee in DictEmployeeSerializer(employees, many=True).data}
|
||||||
result_dict = {result['answer__id']: {'count': result['count'], 'employee': employee_dict.get(int(result['answer__name']))} for result in results}
|
result_dict = {result['answer__id']: {
|
||||||
|
'count': result['count'],
|
||||||
|
**({'employee': employee_dict.get(int(result['answer__name']), None)} if result['answer__name'] in answers_employee else {})
|
||||||
|
}
|
||||||
|
for result in results
|
||||||
|
}
|
||||||
for question in serialized_data['questions']:
|
for question in serialized_data['questions']:
|
||||||
for answer in question['answers']:
|
for answer in question['answers']:
|
||||||
answer_data = result_dict.get(answer['id'], {})
|
answer_data = result_dict.get(answer['id'], {})
|
||||||
|
|||||||
Reference in new issue
Block a user