Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

mattermost_import: Log when processing messages.

PieterCK45b396393ffe
diff --git a/zerver/lib/utils.py b/zerver/lib/utils.py
index 326922c103a..9895d95346c 100644
--- a/zerver/lib/utils.py
+++ b/zerver/lib/utils.py
@@ -1,4 +1,5 @@
import hashlib
+import logging
import re
import secrets
from collections.abc import Callable
@@ -30,13 +31,14 @@ def process_list_in_batches(
lst: list[T], chunk_size: int, process_batch: Callable[[list[T]], None]
) -> None:
offset = 0
-
+ total_message_length = len(lst)
while True:
items = lst[offset : offset + chunk_size]
if not items:
break
process_batch(items)
- offset += chunk_size
+ offset = min(offset + chunk_size, total_message_length)
+ logging.info("Processed messages up to %s / %s", offset, total_message_length)
def optional_bytes_to_mib(value: int | None) -> int | None:
diff --git a/zerver/tests/test_rocketchat_importer.py b/zerver/tests/test_rocketchat_importer.py
index b9e98a09f87..f39fed4625f 100644
--- a/zerver/tests/test_rocketchat_importer.py
+++ b/zerver/tests/test_rocketchat_importer.py
@@ -912,6 +912,8 @@ class RocketChatImporter(ZulipTestCase):
"INFO:root:Done processing emoji",
"INFO:root:Direct message group channel found. UIDs: ['LdBZ7kPxtKESyHPEe', 'M2sXGqoQRJQwQoXY2', 'os6N2Xg2JkNMCSW9Z']",
"INFO:root:skipping direct messages discussion mention: Discussion with Hermione",
+ "INFO:root:Processed messages up to 35 / 35",
+ "INFO:root:Processed messages up to 8 / 8",
"INFO:root:Exporting migration status",
],
)