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.
This commit is contained in:
Steve Howell 2021-12-08 14:21:32 +00:00 committed by Tim Abbott
parent f8ed099d3c
commit 6ec49951c6
1 changed files with 2 additions and 2 deletions

View File

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