attachments: Stop fetching attachments in / endpoint.

We only use this data in a rarely-used settings screen, and it can be
large after years of posting screenshots.

So optimize the performance of / by just loading these data when we
actually visit the page.

This saves about 300ms of runtime for loading the home view for my
user account on chat.zulip.org.
This commit is contained in:
Tim Abbott
2018-05-04 15:27:25 -07:00
parent 60185dddfd
commit 69c4645bd2
6 changed files with 27 additions and 14 deletions

View File

@@ -45,7 +45,6 @@ class HomeTest(ZulipTestCase):
# Keep this list sorted!!!
expected_keys = [
"alert_words",
"attachments",
"avatar_source",
"avatar_url",
"avatar_url_medium",
@@ -198,7 +197,7 @@ class HomeTest(ZulipTestCase):
with patch('zerver.lib.cache.cache_set') as cache_mock:
result = self._get_home_page(stream='Denmark')
self.assert_length(queries, 42)
self.assert_length(queries, 41)
self.assert_length(cache_mock.call_args_list, 7)
html = result.content.decode('utf-8')
@@ -242,7 +241,7 @@ class HomeTest(ZulipTestCase):
result = self._get_home_page()
self.assertEqual(result.status_code, 200)
self.assert_length(cache_mock.call_args_list, 6)
self.assert_length(queries, 39)
self.assert_length(queries, 37)
@slow("Creates and subscribes 10 users in a loop. Should use bulk queries.")
def test_num_queries_with_streams(self) -> None:
@@ -274,7 +273,7 @@ class HomeTest(ZulipTestCase):
with queries_captured() as queries2:
result = self._get_home_page()
self.assert_length(queries2, 36)
self.assert_length(queries2, 35)
# Do a sanity check that our new streams were in the payload.
html = result.content.decode('utf-8')