diff --git a/src/apps/answers/service.py b/src/apps/answers/service.py index 6c6bb2adf2a..13883493721 100644 --- a/src/apps/answers/service.py +++ b/src/apps/answers/service.py @@ -1235,25 +1235,25 @@ async def get_export_data( # noqa: C901 flows_coro = FlowsHistoryCRUD(self.session).get_by_id_versions(list(flow_hist_ids)) user_map_coro = AppletAccessCRUD(self.session).get_respondent_export_data(applet_id, list(respondent_ids)) subject_map_coro = AppletAccessCRUD(self.session).get_subject_export_data(applet_id, list(subject_ids)) - current_user_subject_coro = SubjectsCrud(self.session).get_user_subject(self.user_id, applet_id) # type: ignore[arg-type] coros_result = await asyncio.gather( flows_coro, user_map_coro, subject_map_coro, - current_user_subject_coro, return_exceptions=True, ) for res in coros_result: if isinstance(res, BaseException): raise res - flows, user_map, subject_map, current_user = coros_result + flows, user_map, subject_map = coros_result flow_map = {flow.id_version: flow for flow in flows} # type: ignore for answer in answers: respondent = user_map[answer.respondent_id] # type: ignore - answer.respondent_secret_id = current_user.secret_user_id # type: ignore + answer.respondent_secret_id = ( + subject_map.get(answer.input_subject_id).secret_id if answer.input_subject_id else None # type: ignore + ) answer.source_secret_id = ( subject_map.get(answer.source_subject_id).secret_id if answer.source_subject_id else None # type: ignore