Skip to content

Commit 158348a

Browse files
Abdellatif Missoumiqcoumes
authored andcommitted
add nb batch
1 parent 1ce5581 commit 158348a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

django_opensearch_dsl/documents.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,17 @@ def get_indexing_queryset(
116116
max_value = result["max_pk"] + 1
117117

118118
done = 0
119+
current_batch = 0
120+
total_batches = (max_value - min_value + chunk_size - 1) // chunk_size
119121
start = time.time()
120122
if verbose:
121123
stdout.write(f"{action} {model}: 0% ({self._eta(start, done, count)})\r")
122124

123125
for pk_offset in range(min_value, max_value, chunk_size):
126+
current_batch += 1
124127
max_pk = min(pk_offset + self.django.queryset_pagination, max_value)
125128
batch_qs = qs.filter(pk__gte=pk_offset, pk__lt=max_pk)
126-
stdout.write(f"Processing batch with pk from {pk_offset} to {max_pk - 1}\n")
129+
stdout.write(f"Processing batch {current_batch}/{total_batches} with pk from {pk_offset} to {max_pk - 1}\n")
127130
for obj in batch_qs:
128131
done += 1
129132
if done % chunk_size == 0:

0 commit comments

Comments
 (0)