Skip to content
Snippets Groups Projects

Load minimal data & add more corpus limitations to ListProcessElements

Merged Bastien Abadie requested to merge perf-list-process-elements into master
1 file
+ 11
2
Compare changes
  • Side-by-side
  • Inline
+ 11
2
@@ -909,7 +909,10 @@ class ListProcessElements(CustomPaginationViewMixin, ListAPIView):
if elements is not None and dataimport.load_children:
# Load all the children elements whose path contains the pre-selected elements
# Those children are appended to the pre-selection
elements |= Element.objects.filter(paths__path__overlap=map(str, elements.values_list('id', flat=True))).filter(**base_filters)
elements |= Element.objects.filter(
paths__path__overlap=map(str, elements.values_list('id', flat=True)),
**base_filters
)
# Load the full corpus, only when elements has not been populated before
if elements is None:
@@ -926,11 +929,17 @@ class ListProcessElements(CustomPaginationViewMixin, ListAPIView):
return elements.values('id', 'type__slug', 'name')
def get_filters(self, dataimport):
filters = {}
filters = {
"corpus_id": dataimport.corpus_id,
}
if dataimport.name_contains:
filters['name__contains'] = dataimport.name_contains
if dataimport.element_type:
filters['type_id'] = dataimport.element_type_id
else:
# Limit the scope of types available to merge
# This prevent memory from exploding when no type is selected
filters['type__corpus_id'] = dataimport.corpus_id
return filters
Loading