Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
streams: Remove get_client_data function.
Sahil Batra2533e64be6da
diff --git a/zerver/lib/streams.py b/zerver/lib/streams.pyindex 67e4fb3e6f7..8acca6d7858 100644--- a/zerver/lib/streams.py+++ b/zerver/lib/streams.py@@ -846,8 +846,9 @@ def stream_to_dict(stream: Stream) -> APIStreamDict:def get_web_public_streams(realm: Realm) -> List[APIStreamDict]: # nocoveragequery = get_web_public_streams_queryset(realm)- streams = Stream.get_client_data(query)- return streams+ streams = query.only(*Stream.API_FIELDS)+ stream_dicts = [stream_to_dict(stream) for stream in streams]+ return stream_dictsdef do_get_streams(@@ -870,7 +871,7 @@ def do_get_streams(query = Stream.objects.filter(realm=user_profile.realm, deactivated=False)if include_all_active:- streams = Stream.get_client_data(query)+ streams = query.only(*Stream.API_FIELDS)else:# We construct a query as the or (|) of the various sources# this user requested streams from.@@ -908,16 +909,17 @@ def do_get_streams(if query_filter is not None:query = query.filter(query_filter)- streams = Stream.get_client_data(query)+ streams = query.only(*Stream.API_FIELDS)else:# Don't bother going to the database with no valid sources- streams = []+ return []- streams.sort(key=lambda elt: elt["name"])+ stream_dicts = [stream_to_dict(stream) for stream in streams]+ stream_dicts.sort(key=lambda elt: elt["name"])if include_default:default_stream_ids = get_default_stream_ids_for_realm(user_profile.realm_id)- for stream in streams:+ for stream in stream_dicts:stream["is_default"] = stream["stream_id"] in default_stream_ids- return streams+ return stream_dictsdiff --git a/zerver/models.py b/zerver/models.pyindex 3adf8ea7e44..f0a56e856f6 100644--- a/zerver/models.py+++ b/zerver/models.py@@ -2701,11 +2701,6 @@ class Stream(models.Model):"can_remove_subscribers_group_id",]- @staticmethod- def get_client_data(query: QuerySet["Stream"]) -> List[APIStreamDict]:- query = query.only(*Stream.API_FIELDS)- return [row.to_dict() for row in query]-def to_dict(self) -> APIStreamDict:return APIStreamDict(can_remove_subscribers_group=self.can_remove_subscribers_group_id,