(
instance: FeatureState,
history_instance: HistoricalFeatureState,
event_type: WebhookEventType,
)
| 65 | |
| 66 | |
| 67 | def _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 | |
| 89 | def _get_previous_feature_state_for_change_request( |
no test coverage detected
searching dependent graphs…