From b8d102aa8de21ed0950287eb269568688930f763 Mon Sep 17 00:00:00 2001 From: Wolkenfarmer Date: Thu, 17 Oct 2024 12:49:06 +0200 Subject: [PATCH] #330 backend: always send continuous variable update last --- .../game/channel_notifications.py | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/backend/dps_training_k/game/channel_notifications.py b/backend/dps_training_k/game/channel_notifications.py index 70f7b6eb..f2724e03 100644 --- a/backend/dps_training_k/game/channel_notifications.py +++ b/backend/dps_training_k/game/channel_notifications.py @@ -135,12 +135,6 @@ def dispatch_event(cls, applied_action, changes, is_updated): channel, applied_action, ) - if ( - applied_action.state_name == models.ActionInstanceStateNames.FINISHED - and applied_action.patient_instance - ): - event = {"type": ChannelEventTypes.CONTINUOUS_VARIABLE_UPDATE} - cls._notify_group(channel, event) if applied_action.template.relocates: if ( applied_action.state_name @@ -165,6 +159,14 @@ def dispatch_event(cls, applied_action, changes, is_updated): # always send action list event cls._notify_action_event(ChannelEventTypes.ACTION_LIST_EVENT, channel) + if ( + "current_state" in changes + and applied_action.state_name == models.ActionInstanceStateNames.FINISHED + and applied_action.patient_instance + ): + event = {"type": ChannelEventTypes.CONTINUOUS_VARIABLE_UPDATE} + cls._notify_group(channel, event) + @classmethod def _notify_action_event(cls, event_type, channel, applied_action=None): # ACTION_LIST_EVENT is a special case, as it does not need an associated applied_Action @@ -489,15 +491,15 @@ def get_exercise(cls, patient_instance): @classmethod def _notify_patient_state_change(cls, patient_instance): channel = cls.get_group_name(patient_instance) - event = {"type": ChannelEventTypes.CONTINUOUS_VARIABLE_UPDATE} - cls._notify_group(channel, event) - event = { "type": ChannelEventTypes.STATE_CHANGE_EVENT, "patient_instance_pk": patient_instance.id, } cls._notify_group(channel, event) + event = {"type": ChannelEventTypes.CONTINUOUS_VARIABLE_UPDATE} + cls._notify_group(channel, event) + @classmethod def _notify_patient_move(cls, patient_instance): channel = cls.get_group_name(patient_instance.exercise)