Commit 50cb8355 authored by Kenzo-Hugo Hillion's avatar Kenzo-Hugo Hillion
Browse files

improve performances to get CSV from genes endpoint

parent 9551934d
Pipeline #32725 passed with stages
in 3 minutes and 27 seconds
......@@ -83,8 +83,8 @@ class GeneViewSet(BulkViewSet):
return ','.join([str(item) for item in gene_items])
def _build_csv_response(self):
queryset = self.get_queryset().select_related("taxonomy").prefetch_related("functions")
queryset = self.filter_queryset(queryset)
queryset = self.filter_queryset(self.get_queryset())
queryset = queryset.select_related("taxonomy").prefetch_related("functions")
if self._check_too_many_genes(queryset):
return self.too_many_genes_error_response
with StringIO() as csv_file:
......@@ -94,7 +94,7 @@ class GeneViewSet(BulkViewSet):
'kegg_id', 'eggnog_id',
])
csv_file.write(f"{header}\n")
for gene in queryset.iterator():
for gene in queryset:
csv_file.write(f"{self._get_metadata_line(gene)}\n")
# generate the file
response = HttpResponse(csv_file.getvalue(), content_type='text/csv')
......
......@@ -168,6 +168,7 @@ LOGGING = {
'disable_existing_loggers': False,
'handlers': {
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
},
},
......@@ -176,8 +177,8 @@ LOGGING = {
'handlers': ['console'],
'level': env.str('DJANGO_LOG_LEVEL', 'INFO'),
},
'metagenedb': {
'level': env.str('DJANGO_LOG_LEVEL', 'INFO'),
},
'django.db.backends': {
'level': env.str('DB_LOG_LEVEL', 'INFO'),
}
},
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment