MCPcopy Create free account
hub / github.com/Flagsmith/flagsmith / _get_previous_state

Function _get_previous_state

api/features/tasks.py:67–86  ·  view source on GitHub ↗
(
    instance: FeatureState,
    history_instance: HistoricalFeatureState,
    event_type: WebhookEventType,
)

Source from the content-addressed store, hash-verified

65
66
67def _get_previous_state(
68 instance: FeatureState,
69 history_instance: HistoricalFeatureState,
70 event_type: WebhookEventType,
71) -> dict[str, Any] | None:
72 if event_type == WebhookEventType.FLAG_DELETED:
73 return _get_feature_state_webhook_data(instance)
74
75 # Change requests create a new FeatureState with its own history
76 if instance.change_request_id is not None:
77 previous_fs = _get_previous_feature_state_for_change_request(instance)
78 if previous_fs:
79 return _get_feature_state_webhook_data(previous_fs)
80 return None
81
82 if history_instance and history_instance.prev_record:
83 return _get_feature_state_webhook_data(
84 history_instance.prev_record.instance, previous=True
85 )
86 return None
87
88
89def _get_previous_feature_state_for_change_request(

Callers 1

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…