openapi: Pass required arguments to select_related call.

This commit adds code to pass all the required arguments to
select_related call for Message objects such that only the
required related fields are fetched from the database.

Previously, we did not pass any arguments to select_related,
so all the directly and indirectly related fields were fetched
when many of them were actually not being used and made the
query unnecessarily complex.
This commit is contained in:
Sahil Batra 2023-08-01 21:21:48 +05:30 committed by Tim Abbott
parent 7ff5423e21
commit a6df377688
1 changed files with 1 additions and 1 deletions

View File

@ -131,7 +131,7 @@ def add_emoji_to_message() -> Dict[str, object]:
emoji_code = "1f419"
reaction_type = "unicode_emoji"
message = Message.objects.select_related().get(id=message_id)
message = Message.objects.select_related(*Message.DEFAULT_SELECT_RELATED).get(id=message_id)
do_add_reaction(user_profile, message, emoji_name, emoji_code, reaction_type)
return {}