Skip to content

Commit

Permalink
OpenConceptLab/ocl_issues#910 | ordering concepts/mappings | fixing b…
Browse files Browse the repository at this point in the history
…atch size typo
  • Loading branch information
snyaggarwal committed Aug 13, 2021
1 parent 9c12c81 commit cb36b6b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions core/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def write_export_file(
resource_string = json.dumps(data, cls=encoders.JSONEncoder)
logger.info('Done serializing attributes.')

batch_size = 2
batch_size = 100
is_collection = resource_type == 'collection'

if is_collection:
Expand Down Expand Up @@ -237,7 +237,8 @@ def write_export_file(

while batch_queryset.exists():
logger.info('Serializing concepts %d - %d...' % (start + 1, end))
queryset = Concept.objects.filter(id__in=batch_queryset.values_list('concept_id')).filter(**filters)
queryset = Concept.objects.filter(
id__in=batch_queryset.values_list('concept_id')).filter(**filters).order_by('-id')
if queryset.exists():
if start > 0:
with open('export.json', 'a') as out:
Expand Down Expand Up @@ -297,7 +298,8 @@ def write_export_file(

while batch_queryset.exists():
logger.info('Serializing mappings %d - %d...' % (start + 1, start + batch_size))
queryset = Mapping.objects.filter(id__in=batch_queryset.values_list('mapping_id')).filter(**filters)
queryset = Mapping.objects.filter(
id__in=batch_queryset.values_list('mapping_id')).filter(**filters).order_by('-id')
if queryset.exists():
if start > 0:
with open('export.json', 'a') as out:
Expand Down

0 comments on commit cb36b6b

Please sign in to comment.