default_streams: Remove get_default_streams_for_realm_as_dicts.

Since get_default_streams_for_realm_as_dicts function was only
used in tests, this commit removes it and updates the test to
use the function which returns Stream objects instead of dicts.

This commit also removes Stream.to_dict function which is no
longer used.
This commit is contained in:
Sahil Batra
2024-12-17 14:46:27 +05:30
committed by Tim Abbott
parent 1182e7e350
commit a9bd614df3
5 changed files with 8 additions and 53 deletions

View File

@@ -1,4 +1,3 @@
from zerver.lib.types import DefaultStreamDict
from zerver.models import DefaultStream, Stream
@@ -18,13 +17,3 @@ def get_slim_realm_default_streams(realm_id: int) -> list[Stream]:
def get_default_stream_ids_for_realm(realm_id: int) -> set[int]:
return set(DefaultStream.objects.filter(realm_id=realm_id).values_list("stream_id", flat=True))
def get_default_streams_for_realm_as_dicts(realm_id: int) -> list[DefaultStreamDict]:
"""
Return all the default streams for a realm using a list of dictionaries sorted
by stream name.
"""
streams = get_slim_realm_default_streams(realm_id)
stream_dicts = [stream.to_dict() for stream in streams]
return sorted(stream_dicts, key=lambda stream: stream["name"])