performance: Use ORM to fetch sender in render_markdown.

In 709493cd75 (Feb 2017)
I added code to render_markdown that re-fetched the
sender of the message, to detect whether the message is
a bot.

It's better to just let the ORM fetch this.  The
message object should already have sender.

The diff makes it look like we are saving round trips
to the database, which is true in some cases.  For
the main message-send codepath, though, we are only
saving a trip to memcached, since the middleware
will have put our sender's user object into the
cache.  The test_message_send test calls internally
to check_send_stream_message, so it was actually
hitting the database in render_markdown (prior to
my change).
This commit is contained in:
Steve Howell
2020-11-04 12:54:10 +00:00
committed by Tim Abbott
parent 637f596751
commit c1f134a3a4
6 changed files with 12 additions and 13 deletions

View File

@@ -1194,7 +1194,7 @@ class StreamMessagesTest(ZulipTestCase):
body=content,
)
self.assert_length(queries, 13)
self.assert_length(queries, 12)
def test_stream_message_dict(self) -> None:
user_profile = self.example_user('iago')