From 5862e054e3b746cbfdb8d5329d4698bf787ae1fb Mon Sep 17 00:00:00 2001 From: FinnStutzenstein Date: Wed, 27 Sep 2017 13:06:21 +0200 Subject: [PATCH] Naive projector prioritization --- CHANGELOG | 1 + openslides/utils/autoupdate.py | 52 +++++++++++++++++----------------- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index e29d1f21a..920e812cb 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -87,6 +87,7 @@ Core: - Added 'go to top'-link [#3404]. - Added caching for the index views. When using a Webserver for serving static files see the example configuration in the PR [#3419]. +- Added projector prioritization [#3425]. Mediafiles: - Fixed reloading of PDF on page change [#3274]. diff --git a/openslides/utils/autoupdate.py b/openslides/utils/autoupdate.py index c87564110..4def9179a 100644 --- a/openslides/utils/autoupdate.py +++ b/openslides/utils/autoupdate.py @@ -251,6 +251,32 @@ def send_data(message: ChannelMessageFormat) -> None: """ collection_elements = from_channel_message(message) + # Check whether broadcast is active at the moment and set the local + # projector queryset. + if config['projector_broadcast'] > 0: + queryset = Projector.objects.filter(pk=config['projector_broadcast']) + else: + queryset = Projector.objects.all() + + # Loop over all projectors and send data that they need. + for projector in queryset: + output = [] + for collection_element in collection_elements: + if collection_element.is_deleted(): + output.append(collection_element.as_autoupdate_for_projector()) + else: + for element in projector.get_collection_elements_required_for_this(collection_element): + output.append(element.as_autoupdate_for_projector()) + if output: + if config['projector_broadcast'] > 0: + send_or_wait( + Group('projector-all').send, + {'text': json.dumps(output)}) + else: + send_or_wait( + Group('projector-{}'.format(projector.pk)).send, + {'text': json.dumps(output)}) + # Send data to site users. for user_id, channel_names in websocket_user_cache.get_all().items(): if not user_id: @@ -282,32 +308,6 @@ def send_data(message: ChannelMessageFormat) -> None: for channel_name in channel_names: send_or_wait(Channel(channel_name).send, {'text': json.dumps(output)}) - # Check whether broadcast is active at the moment and set the local - # projector queryset. - if config['projector_broadcast'] > 0: - queryset = Projector.objects.filter(pk=config['projector_broadcast']) - else: - queryset = Projector.objects.all() - - # Loop over all projectors and send data that they need. - for projector in queryset: - output = [] - for collection_element in collection_elements: - if collection_element.is_deleted(): - output.append(collection_element.as_autoupdate_for_projector()) - else: - for element in projector.get_collection_elements_required_for_this(collection_element): - output.append(element.as_autoupdate_for_projector()) - if output: - if config['projector_broadcast'] > 0: - send_or_wait( - Group('projector-all').send, - {'text': json.dumps(output)}) - else: - send_or_wait( - Group('projector-{}'.format(projector.pk)).send, - {'text': json.dumps(output)}) - def inform_changed_data(instances: Union[Iterable[Model], Model], information: Dict[str, Any]=None) -> None: """