mattermost_import: Log when processing messages.

This logs a line for every batch of messages processed by
process_list_in_batches.
This commit is contained in:
PieterCK
2025-05-21 09:22:14 +07:00
committed by Tim Abbott
parent 8830373c9e
commit 45b396393f
2 changed files with 6 additions and 2 deletions

View File

@@ -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:

View File

@@ -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",
],
)