From 35c59fc4d74b4e8f3d04e0a8a2c61c44eb948cf6 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Tue, 9 Aug 2016 18:28:46 -0700 Subject: [PATCH] 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. --- zerver/lib/export.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/zerver/lib/export.py b/zerver/lib/export.py index 5c0967a8ce..9c981db28c 100644 --- a/zerver/lib/export.py +++ b/zerver/lib/export.py @@ -255,16 +255,25 @@ def export_messages(realm, user_profile_ids, recipient_ids, if len(message_chunk) == 0: break + # Figure out the name of our shard file. message_filename = os.path.join(output_dir, "messages-%06d.json" % (dump_file_id,)) message_filename += '.partial' 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['zerver_message'] = message_chunk - floatify_datetime_fields(output, 'zerver_message') + output['zerver_message'] = table_data['zerver_message'] output['zerver_userprofile_ids'] = list(user_profile_ids) output['realm_id'] = realm.id + # And write the data. write_message_export(message_filename, output) min_id = max(message_ids) dump_file_id += 1