| 7 | |
| 8 | |
| 9 | class EnvironmentManager(SoftDeleteManager): # type: ignore[misc] |
| 10 | def filter_for_document_builder( # type: ignore[no-untyped-def] |
| 11 | self, |
| 12 | *args, |
| 13 | extra_select_related: list[str] | None = None, |
| 14 | extra_prefetch_related: list[Prefetch | str] | None = None, # type: ignore[type-arg] |
| 15 | **kwargs, |
| 16 | ): |
| 17 | return ( |
| 18 | super() |
| 19 | .select_related( |
| 20 | "project", |
| 21 | "project__organisation", |
| 22 | *extra_select_related or (), |
| 23 | ) |
| 24 | .prefetch_related( |
| 25 | Prefetch( |
| 26 | "project__segments", |
| 27 | queryset=Segment.live_objects.all(), |
| 28 | ), |
| 29 | "project__segments__rules", |
| 30 | "project__segments__rules__rules", |
| 31 | "project__segments__rules__conditions", |
| 32 | "project__segments__rules__rules__conditions", |
| 33 | "project__segments__rules__rules__rules", |
| 34 | Prefetch( |
| 35 | "project__segments__feature_segments", |
| 36 | queryset=FeatureSegment.objects.select_related("segment"), |
| 37 | ), |
| 38 | Prefetch( |
| 39 | "project__segments__feature_segments__feature_states", |
| 40 | queryset=FeatureState.objects.select_related( |
| 41 | "feature", |
| 42 | "feature_state_value", |
| 43 | "environment", |
| 44 | "environment_feature_version", |
| 45 | ), |
| 46 | ), |
| 47 | Prefetch( |
| 48 | "project__segments__feature_segments__feature_states__multivariate_feature_state_values", |
| 49 | queryset=MultivariateFeatureStateValue.objects.select_related( |
| 50 | "multivariate_feature_option" |
| 51 | ), |
| 52 | ), |
| 53 | *extra_prefetch_related or (), |
| 54 | ) |
| 55 | .filter(*args, **kwargs) |
| 56 | ) |
| 57 | |
| 58 | def get_queryset(self): # type: ignore[no-untyped-def] |
| 59 | return super().get_queryset().select_related("project", "project__organisation") |
| 60 | |
| 61 | def get_by_natural_key(self, api_key): # type: ignore[no-untyped-def] |
| 62 | return self.get(api_key=api_key) |
no outgoing calls
no test coverage detected
searching dependent graphs…