Naive projector prioritization

This commit is contained in:
FinnStutzenstein 2017-09-27 13:06:21 +02:00
parent c269ae5cf8
commit 5862e054e3
2 changed files with 27 additions and 26 deletions

View File

@ -87,6 +87,7 @@ Core:
- Added 'go to top'-link [#3404]. - Added 'go to top'-link [#3404].
- Added caching for the index views. When using a Webserver for serving - Added caching for the index views. When using a Webserver for serving
static files see the example configuration in the PR [#3419]. static files see the example configuration in the PR [#3419].
- Added projector prioritization [#3425].
Mediafiles: Mediafiles:
- Fixed reloading of PDF on page change [#3274]. - Fixed reloading of PDF on page change [#3274].

View File

@ -251,6 +251,32 @@ def send_data(message: ChannelMessageFormat) -> None:
""" """
collection_elements = from_channel_message(message) 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. # Send data to site users.
for user_id, channel_names in websocket_user_cache.get_all().items(): for user_id, channel_names in websocket_user_cache.get_all().items():
if not user_id: if not user_id:
@ -282,32 +308,6 @@ def send_data(message: ChannelMessageFormat) -> None:
for channel_name in channel_names: for channel_name in channel_names:
send_or_wait(Channel(channel_name).send, {'text': json.dumps(output)}) 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: def inform_changed_data(instances: Union[Iterable[Model], Model], information: Dict[str, Any]=None) -> None:
""" """