home: Remove unused has_mobile_devices parameter.

This parameter has never been used, and causes an unnecessary database
query.

We keep the num_push_devices_for_user function, since we may have uses
for it down the line.

Fixes part of #14166.
This commit is contained in:
Tim Abbott 2021-05-14 17:47:40 -07:00 committed by Tim Abbott
parent 1428310973
commit e1c885aeb9
3 changed files with 3 additions and 10 deletions

View File

@ -157,7 +157,6 @@ def build_page_params_for_home_page_load(
user_profile: Optional[UserProfile],
realm: Realm,
insecure_desktop_app: bool,
has_mobile_devices: bool,
narrow: List[List[str]],
narrow_stream: Optional[Stream],
narrow_topic: Optional[str],
@ -243,7 +242,6 @@ def build_page_params_for_home_page_load(
first_in_realm=first_in_realm,
prompt_for_invites=prompt_for_invites,
furthest_read_time=furthest_read_time,
has_mobile_devices=has_mobile_devices,
bot_types=get_bot_types(user_profile),
two_fa_enabled=two_fa_enabled,
# Adding two_fa_enabled as condition saves us 3 queries when

View File

@ -89,7 +89,6 @@ class HomeTest(ZulipTestCase):
"furthest_read_time",
"giphy_api_key",
"giphy_rating_options",
"has_mobile_devices",
"has_zoom_token",
"high_contrast_mode",
"hotspots",
@ -276,7 +275,7 @@ class HomeTest(ZulipTestCase):
set(result["Cache-Control"].split(", ")), {"must-revalidate", "no-store", "no-cache"}
)
self.assert_length(queries, 41)
self.assert_length(queries, 40)
self.assert_length(cache_mock.call_args_list, 5)
html = result.content.decode("utf-8")
@ -356,7 +355,7 @@ class HomeTest(ZulipTestCase):
result = self._get_home_page()
self.check_rendered_logged_in_app(result)
self.assert_length(cache_mock.call_args_list, 6)
self.assert_length(queries, 38)
self.assert_length(queries, 37)
def test_num_queries_with_streams(self) -> None:
main_user = self.example_user("hamlet")
@ -387,7 +386,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")

View File

@ -19,7 +19,6 @@ from zerver.lib.home import (
get_user_permission_info,
promote_sponsoring_zulip_in_realm,
)
from zerver.lib.push_notifications import num_push_devices_for_user
from zerver.lib.streams import access_stream_by_name
from zerver.lib.subdomains import get_subdomain
from zerver.lib.users import compute_show_invites_and_add_streams
@ -195,14 +194,11 @@ def home_real(request: HttpRequest) -> HttpResponse:
# The current tutorial doesn't super make sense for logged-out users.
needs_tutorial = False
has_mobile_devices = user_profile is not None and num_push_devices_for_user(user_profile) > 0
queue_id, page_params = build_page_params_for_home_page_load(
request=request,
user_profile=user_profile,
realm=realm,
insecure_desktop_app=insecure_desktop_app,
has_mobile_devices=has_mobile_devices,
narrow=narrow,
narrow_stream=narrow_stream,
narrow_topic=narrow_topic,