mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	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:
		@@ -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')
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user