From 6ec49951c68355e90c2ed7dad32a15556ea6368e Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Wed, 8 Dec 2021 14:21:32 +0000 Subject: [PATCH] minor: Avoid creating intermediate list for message_ids. This probably just postpones the list creation until Django builds the "IN" query, but semantically it's good to work in sets where we don't have any meaningful ordering of the list that gets used. --- zerver/lib/export.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zerver/lib/export.py b/zerver/lib/export.py index 5f464e7679..9d3aa47108 100644 --- a/zerver/lib/export.py +++ b/zerver/lib/export.py @@ -1145,13 +1145,13 @@ def export_usermessages_batch( management command).""" with open(input_path, "rb") as input_file: output = orjson.loads(input_file.read()) - message_ids = [item["id"] for item in output["zerver_message"]] + message_ids = {item["id"] for item in output["zerver_message"]} user_profile_ids = set(output["zerver_userprofile_ids"]) del output["zerver_userprofile_ids"] realm = Realm.objects.get(id=output["realm_id"]) del output["realm_id"] output["zerver_usermessage"] = fetch_usermessages( - realm, set(message_ids), user_profile_ids, output_path, consent_message_id + realm, message_ids, user_profile_ids, output_path, consent_message_id ) write_message_export(output_path, output) os.unlink(input_path)