mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 08:56:10 +00:00
export: Clean up export_messages().
This is pretty minor cleanup, but it makes it a little more explicit what we're writing to the shard file, and it allows us to use a more specific mypy type when calling floatify_datetime_fields.
This commit is contained in:
@@ -255,16 +255,25 @@ def export_messages(realm, user_profile_ids, recipient_ids,
|
|||||||
if len(message_chunk) == 0:
|
if len(message_chunk) == 0:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
# Figure out the name of our shard file.
|
||||||
message_filename = os.path.join(output_dir, "messages-%06d.json" % (dump_file_id,))
|
message_filename = os.path.join(output_dir, "messages-%06d.json" % (dump_file_id,))
|
||||||
message_filename += '.partial'
|
message_filename += '.partial'
|
||||||
logging.info("Fetched Messages for %s" % (message_filename,))
|
logging.info("Fetched Messages for %s" % (message_filename,))
|
||||||
|
|
||||||
|
# Clean up our messages.
|
||||||
|
table_data = {} # type: TableData
|
||||||
|
table_data['zerver_message'] = message_chunk
|
||||||
|
floatify_datetime_fields(table_data, 'zerver_message')
|
||||||
|
|
||||||
|
# Build up our output for the .partial file, which needs
|
||||||
|
# a list of user_profile_ids to search for (as well as
|
||||||
|
# the realm id).
|
||||||
output = {} # type: MessageOutput
|
output = {} # type: MessageOutput
|
||||||
output['zerver_message'] = message_chunk
|
output['zerver_message'] = table_data['zerver_message']
|
||||||
floatify_datetime_fields(output, 'zerver_message')
|
|
||||||
output['zerver_userprofile_ids'] = list(user_profile_ids)
|
output['zerver_userprofile_ids'] = list(user_profile_ids)
|
||||||
output['realm_id'] = realm.id
|
output['realm_id'] = realm.id
|
||||||
|
|
||||||
|
# And write the data.
|
||||||
write_message_export(message_filename, output)
|
write_message_export(message_filename, output)
|
||||||
min_id = max(message_ids)
|
min_id = max(message_ids)
|
||||||
dump_file_id += 1
|
dump_file_id += 1
|
||||||
|
|||||||
Reference in New Issue
Block a user