mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 14:35:27 +00:00
streams: Optimize code for computing stream objects.
This commit updates code to optimize code for computing stream
objects to be sent with stream creation event and in response
for 'GET /streams/{stream_id}' endpoint by optimizing number
of queries while computing values for group permission settings.
This change does not benefit much currently as we only have one
stream group permission setting, but is important before we add
more stream permission settings.
There are a couple of places left where we can still optimize
the code and that would be done in further commits.
This commit is contained in:
@@ -928,7 +928,8 @@ def stream_to_dict(
|
||||
def get_web_public_streams(realm: Realm) -> list[APIStreamDict]: # nocoverage
|
||||
query = get_web_public_streams_queryset(realm)
|
||||
streams = query.only(*Stream.API_FIELDS)
|
||||
stream_dicts = [stream_to_dict(stream) for stream in streams]
|
||||
setting_groups_dict = get_group_setting_value_dict_for_streams(list(streams))
|
||||
stream_dicts = [stream_to_dict(stream, None, setting_groups_dict) for stream in streams]
|
||||
return stream_dicts
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user