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

Function get_experiment_rollout

api/experimentation/services.py:658–691  ·  view source on GitHub ↗
(experiment: Experiment)

Source from the content-addressed store, hash-verified

656
657
658def get_experiment_rollout(experiment: Experiment) -> dict[str, typing.Any] | None:
659 segment_id = experiment.rollout_segment_id
660 if segment_id is None:
661 return None
662
663 feature_state = FeatureState.objects.get_live_feature_states(
664 environment=experiment.environment,
665 additional_filters=Q(
666 feature_segment__segment_id=segment_id, identity__isnull=True
667 ),
668 feature_id=experiment.feature_id,
669 ).latest("id")
670
671 condition = Condition.objects.get(
672 rule__segment_id=segment_id, operator=PERCENTAGE_SPLIT
673 )
674 value = feature_state.feature_state_value
675 return {
676 "enabled": feature_state.enabled,
677 "rollout_percentage": float(condition.value or 0),
678 "feature_state_value": {
679 "type": _ROLLOUT_VALUE_TYPE.get(value.type or STRING, "string"),
680 "value": (
681 str(value.value).lower() if value.type == BOOLEAN else str(value.value)
682 ),
683 },
684 "multivariate_feature_state_values": [
685 {
686 "multivariate_feature_option": mv.multivariate_feature_option_id,
687 "percentage_allocation": mv.percentage_allocation,
688 }
689 for mv in feature_state.multivariate_feature_state_values.all()
690 ],
691 }
692
693
694def enable_experiment_rollout(experiment: Experiment, author: AuthorData) -> None:

Callers 2

Calls 3

getMethod · 0.45
allMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…