@@ -110,7 +110,13 @@ def _get_filtered_annotations_queryset(self, annotation_filter_options=None):
110
110
return queryset
111
111
112
112
q = reduce (lambda x , y : x | y , q_list )
113
- return queryset .filter (q )
113
+ annotations_qs = queryset .filter (q )
114
+
115
+ # prefetch reviews in LSE
116
+ if hasattr (annotations_qs .model , 'reviews' ):
117
+ annotations_qs = annotations_qs .prefetch_related ('reviews' )
118
+
119
+ return annotations_qs
114
120
115
121
@staticmethod
116
122
def _get_export_serializer_option (serialization_options ):
@@ -144,6 +150,7 @@ def _get_export_serializer_option(serialization_options):
144
150
145
151
def get_task_queryset (self , ids , annotation_filter_options ):
146
152
annotations_qs = self ._get_filtered_annotations_queryset (annotation_filter_options = annotation_filter_options )
153
+
147
154
return (
148
155
Task .objects .filter (id__in = ids )
149
156
.prefetch_related (
@@ -152,7 +159,7 @@ def get_task_queryset(self, ids, annotation_filter_options):
152
159
queryset = annotations_qs ,
153
160
)
154
161
)
155
- .prefetch_related ('predictions' , 'drafts' )
162
+ .prefetch_related ('predictions' , 'drafts' , 'comment_authors' , 'file_upload' )
156
163
)
157
164
158
165
def get_export_data (self , task_filter_options = None , annotation_filter_options = None , serialization_options = None ):
@@ -272,10 +279,10 @@ def export_to_file(self, task_filter_options=None, annotation_filter_options=Non
272
279
self .status = self .Status .COMPLETED
273
280
self .save (update_fields = ['status' ])
274
281
275
- except Exception :
282
+ except Exception as e :
276
283
self .status = self .Status .FAILED
277
284
self .save (update_fields = ['status' ])
278
- logger .exception ('Export was failed' )
285
+ logger .exception ('Export was failed: %s' , e )
279
286
finally :
280
287
self .finished_at = datetime .now ()
281
288
self .save (update_fields = ['finished_at' ])
0 commit comments