Skip to content

Commit 09760ae

Browse files
committed
views: Added stream message weekly count.
This is the second commit of this PR, which adds the option of weekly message count for streams from the Stream info view. The stream info is now updated to contain the option to view the list of members subscribed to a stream along with the weekly count of messages in stream. These statistics help get a better overview of the streams and acts as a feature enhancement. Tests amended.
1 parent 37c2194 commit 09760ae

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

tests/ui_tools/test_popups.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -560,9 +560,11 @@ def mock_external_classes(self, mocker, monkeypatch):
560560
self.controller.model.is_pinned_stream.return_value = False
561561
mocker.patch(VIEWS + ".urwid.SimpleFocusListWalker", return_value=[])
562562
stream_id = 10
563-
self.controller.model.stream_dict = {stream_id: {'name': 'books',
564-
'description': 'hey',
565-
'subscribers': []}}
563+
self.controller.model.stream_dict = {stream_id:
564+
{'name': 'books',
565+
'subscribers': [],
566+
'description': 'hey',
567+
'stream_weekly_traffic': 123}}
566568
self.stream_info_view = StreamInfoView(self.controller, stream_id)
567569

568570
def test_keypress_any_key(self, widget_size):
@@ -580,9 +582,11 @@ def test_keypress_stream_members(self, mocker, key, widget_size):
580582
self.controller.model.is_pinned_stream.return_value = False
581583
mocker.patch(VIEWS + ".urwid.SimpleFocusListWalker", return_value=[])
582584
stream_id = self.stream_info_view.stream_id
583-
self.controller.model.stream_dict = {stream_id: {'name': 'books',
584-
'description': 'hey',
585-
'subscribers': []}}
585+
self.controller.model.stream_dict = {stream_id:
586+
{'name': 'books',
587+
'subscribers': [],
588+
'description': 'hey',
589+
'stream_weekly_traffic': 123}}
586590

587591
stream_info_view = StreamInfoView(self.controller, stream_id)
588592
size = widget_size(stream_info_view)
@@ -610,7 +614,7 @@ def test_keypress_navigation(self, mocker, widget_size,
610614

611615
@pytest.mark.parametrize('key', (*keys_for_command('ENTER'), ' '))
612616
def test_checkbox_toggle_mute_stream(self, mocker, key, widget_size):
613-
mute_checkbox = self.stream_info_view.widgets[6]
617+
mute_checkbox = self.stream_info_view.widgets[7]
614618
toggle_mute_status = self.controller.model.toggle_stream_muted_status
615619
stream_id = self.stream_info_view.stream_id
616620
size = widget_size(mute_checkbox)
@@ -621,7 +625,7 @@ def test_checkbox_toggle_mute_stream(self, mocker, key, widget_size):
621625

622626
@pytest.mark.parametrize('key', (*keys_for_command('ENTER'), ' '))
623627
def test_checkbox_toggle_pin_stream(self, mocker, key, widget_size):
624-
pin_checkbox = self.stream_info_view.widgets[7]
628+
pin_checkbox = self.stream_info_view.widgets[8]
625629
toggle_pin_status = self.controller.model.toggle_stream_pinned_status
626630
stream_id = self.stream_info_view.stream_id
627631
size = widget_size(pin_checkbox)

zulipterminal/ui_tools/views.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,11 +1078,14 @@ def __init__(self, controller: Any, stream_id: int) -> None:
10781078
self.controller = controller
10791079
stream = controller.model.stream_dict[stream_id]
10801080
total_members = len(stream['subscribers'])
1081+
weekly_msg_count = stream['stream_weekly_traffic']
10811082
keys = ', '.join(map(repr, keys_for_command('STREAM_MEMBERS')))
10821083
title = '# {}'.format(stream['name'])
10831084
desc = stream['description']
10841085
stream_info_content = [('', [desc]),
10851086
('Stream Details', [
1087+
('Weekly Message Count',
1088+
str(weekly_msg_count)),
10861089
('Stream Members',
10871090
'[{}] Press {} to view'.format(
10881091
total_members, keys))

0 commit comments

Comments
 (0)