Skip to content

Commit

Permalink
OpenConceptLab/ocl_issues#1713 POST CodeSystem and ValueSet fails due…
Browse files Browse the repository at this point in the history
… to DB cursor being unsupported
  • Loading branch information
rkorytkowski committed Dec 12, 2023
1 parent efb99d8 commit 6ce54d9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 6 additions & 3 deletions core/common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def get_exact_or_criteria(attr, values):
@staticmethod
def batch_index(queryset, document, single_batch=False):
if not get(settings, 'TEST_MODE'):
if single_batch:
if single_batch or not get(settings, 'DB_CURSOR_ON', True):
document().update(queryset, parallel=True)
else:
for batch in queryset.iterator(chunk_size=500):
Expand All @@ -188,8 +188,11 @@ def batch_index(queryset, document, single_batch=False):
@staticmethod
@transaction.atomic
def batch_delete(queryset):
for batch in queryset.iterator(chunk_size=1000):
batch.delete()
if get(settings, 'DB_CURSOR_ON', True):
for batch in queryset.iterator(chunk_size=1000):
batch.delete()
else:
queryset.delete()


class CommonLogoModel(models.Model):
Expand Down
2 changes: 2 additions & 0 deletions core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@
}
}

DB_CURSOR_ON = os.environ.get('DB_CURSOR_ON', True)

ES_HOST = os.environ.get('ES_HOST', 'es') # Deprecated. Use ES_HOSTS instead.
ES_PORT = os.environ.get('ES_PORT', '9200') # Deprecated. Use ES_HOSTS instead.
ES_HOSTS = os.environ.get('ES_HOSTS', None)
Expand Down

0 comments on commit 6ce54d9

Please sign in to comment.