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

Class FeatureStateManager

api/features/managers.py:26–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24
25
26class FeatureStateManager(UUIDNaturalKeyManagerMixin, SoftDeleteManager): # type: ignore[misc]
27 def get_live_feature_states( # type: ignore[no-untyped-def]
28 self,
29 environment: "Environment",
30 additional_filters: Q = None, # type: ignore[assignment]
31 **kwargs,
32 ) -> QuerySet["FeatureState"]:
33 # TODO: replace additional_filters with just using kwargs in calling locations
34
35 now = timezone.now()
36
37 qs_filter = Q(environment=environment, deleted_at__isnull=True)
38 if environment.use_v2_feature_versioning:
39 latest_versions = (
40 EnvironmentFeatureVersion.objects.get_latest_versions_by_environment_id(
41 environment.id
42 )
43 )
44
45 latest_version_uuids = [efv.uuid for efv in latest_versions]
46
47 # Note that since identity overrides aren't part of the versioning system,
48 # we need to make sure we also return them here. We can still then subsequently
49 # filter them out with the `additional_filters` if needed.
50 qs_filter &= Q(
51 Q(environment_feature_version__uuid__in=latest_version_uuids)
52 | Q(identity__isnull=False)
53 )
54 else:
55 qs_filter &= Q(
56 live_from__isnull=False,
57 live_from__lte=now,
58 version__isnull=False,
59 )
60
61 if additional_filters:
62 qs_filter &= additional_filters
63
64 return self.filter(qs_filter, **kwargs) # type: ignore[no-any-return]
65
66
67class FeatureStateValueManager(UUIDNaturalKeyManagerMixin, SoftDeleteManager): # type: ignore[misc]

Callers 1

FeatureStateClass · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…