Skip to content

Commit 5c513dd

Browse files
committed
Unwrap and be happy
1 parent 52e42b2 commit 5c513dd

2 files changed

Lines changed: 8 additions & 20 deletions

File tree

api/features/views.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@
6262
NestedEnvironmentPermissions,
6363
)
6464
from features.value_types import BOOLEAN, INTEGER, STRING
65+
from integrations.flagsmith.client import get_client
6566
from projects.code_references.services import (
6667
annotate_feature_queryset_with_code_references_summary,
67-
is__code_references_ui_stats__enabled,
6868
)
6969
from projects.models import Project
7070
from users.models import FFAdminUser, UserPermissionGroup
@@ -221,7 +221,13 @@ def get_queryset(self): # type: ignore[no-untyped-def]
221221
query_data = query_serializer.validated_data
222222

223223
# TODO: Delete this after https://github.com/flagsmith/flagsmith/issues/6832 is resolved
224-
if is__code_references_ui_stats__enabled(project.organisation):
224+
organisation = project.organisation
225+
flagsmith_client = get_client("local", local_eval=True)
226+
flags = flagsmith_client.get_identity_flags(
227+
organisation.flagsmith_identifier,
228+
traits=organisation.flagsmith_on_flagsmith_api_traits,
229+
)
230+
if flags.is_feature_enabled("code_references_ui_stats"):
225231
queryset = annotate_feature_queryset_with_code_references_summary(queryset)
226232
else:
227233
queryset = queryset.annotate(

api/projects/code_references/services.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import typing
21
from datetime import timedelta
32
from urllib.parse import urljoin
43

@@ -16,7 +15,6 @@
1615
from django.utils import timezone
1716

1817
from features.models import Feature
19-
from integrations.flagsmith.client import get_client
2018
from projects.code_references.constants import (
2119
FEATURE_FLAG_CODE_REFERENCES_RETENTION_DAYS,
2220
)
@@ -27,22 +25,6 @@
2725
VCSProvider,
2826
)
2927

30-
if typing.TYPE_CHECKING:
31-
from organisations.models import Organisation
32-
33-
34-
def is__code_references_ui_stats__enabled(organisation: "Organisation") -> bool:
35-
"""Check if code reference UI stats are enabled for an organisation.
36-
37-
TODO: Delete this after https://github.com/flagsmith/flagsmith/issues/6832 is resolved.
38-
"""
39-
flagsmith_client = get_client("local", local_eval=True)
40-
flags = flagsmith_client.get_identity_flags(
41-
organisation.flagsmith_identifier,
42-
traits=organisation.flagsmith_on_flagsmith_api_traits,
43-
)
44-
return flags.is_feature_enabled("code_references_ui_stats")
45-
4628

4729
def annotate_feature_queryset_with_code_references_summary(
4830
queryset: QuerySet[Feature],

0 commit comments

Comments
 (0)