Skip to content

Commit

Permalink
#330 backend: always send continuous variable update last
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolkenfarmer committed Oct 17, 2024
1 parent 6656c81 commit f90fc06
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions backend/dps_training_k/game/channel_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f90fc06

Please sign in to comment.