Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(workflows): route the blast radius counts through the facade (#109398)

Harley Alexanderc31fe630086c
diff --git a/posthog/clickhouse/test/__snapshots__/test_schema.ambr b/posthog/clickhouse/test/__snapshots__/test_schema.ambr
index 4cb09c78caef..582c008a3f84 100644
--- a/posthog/clickhouse/test/__snapshots__/test_schema.ambr
+++ b/posthog/clickhouse/test/__snapshots__/test_schema.ambr
@@ -2409,7 +2409,7 @@
) ENGINE = ReplicatedMergeTree('/clickhouse/tables/77f1df52-4b43-11e9-910f-b8ca3a9b9f3e_noshard/posthog.ingestion_warnings_v2', '{replica}-{shard}')
PARTITION BY toYYYYMM(timestamp)
ORDER BY (team_id, type, timestamp)
- TTL toDateTime(timestamp) + INTERVAL 90 DAY
+
'''
# ---
@@ -11879,7 +11879,7 @@
) ENGINE = ReplicatedMergeTree('/clickhouse/tables/77f1df52-4b43-11e9-910f-b8ca3a9b9f3e_noshard/posthog.ingestion_warnings_v2', '{replica}-{shard}')
PARTITION BY toYYYYMM(timestamp)
ORDER BY (team_id, type, timestamp)
- TTL toDateTime(timestamp) + INTERVAL 90 DAY
+
'''
# ---
diff --git a/posthog/models/ingestion_warnings/sql_v2.py b/posthog/models/ingestion_warnings/sql_v2.py
index 4755090f8eb4..3d922971fce7 100644
--- a/posthog/models/ingestion_warnings/sql_v2.py
+++ b/posthog/models/ingestion_warnings/sql_v2.py
@@ -60,11 +60,13 @@ CREATE TABLE IF NOT EXISTS {table_name}
) ENGINE = {engine}
PARTITION BY toYYYYMM(timestamp)
ORDER BY (team_id, type, timestamp)
-TTL toDateTime(timestamp) + INTERVAL 90 DAY
+{ttl}
""".format(
table_name=TABLE_NAME,
columns=INGESTION_WARNINGS_V2_COLUMNS,
engine=MergeTreeEngine(TABLE_NAME, replication_scheme=ReplicationScheme.REPLICATED),
+ # ClickHouse applies the TTL on the real clock, so it deletes test rows that have fixed timestamps.
+ ttl="" if settings.TEST else "TTL toDateTime(timestamp) + INTERVAL 90 DAY",
)
diff --git a/products/workflows/backend/facade/blast_radius.py b/products/workflows/backend/facade/blast_radius.py
new file mode 100644
index 000000000000..7b621438e133
--- /dev/null
+++ b/products/workflows/backend/facade/blast_radius.py
@@ -0,0 +1,22 @@
+"""Batch audience sizing and paging, for the audience preview and the Node batch resolver."""
+
+from products.workflows.backend.services.account_audience import is_account_audience, parse_account_audience_filters
+from products.workflows.backend.services.batch_audience import SUPPORTED_DEDUPE_KEYS
+from products.workflows.backend.services.blast_radius import (
+ get_account_audience_ids_page,
+ get_account_audience_size,
+ get_account_group_type_name,
+ get_audience_person_page,
+ get_audience_size,
+)
+
+__all__ = [
+ "SUPPORTED_DEDUPE_KEYS",
+ "get_account_audience_ids_page",
+ "get_account_audience_size",
+ "get_account_group_type_name",
+ "get_audience_person_page",
+ "get_audience_size",
+ "is_account_audience",
+ "parse_account_audience_filters",
+]
diff --git a/products/workflows/backend/facade/contracts.py b/products/workflows/backend/facade/contracts.py
index 955f2dddc95f..9816618c5eb5 100644
--- a/products/workflows/backend/facade/contracts.py
+++ b/products/workflows/backend/facade/contracts.py
@@ -105,6 +105,24 @@ class AccountAudienceProvider(Protocol):
def get_account_group_type_name(self, team: "Team") -> str | None: ...
+@frozen
+class AudienceSize:
+ """How many recipients a batch audience matches, and the most a batch trigger may send to."""
+
+ affected: int
+ total: int
+ limit: int
+ dedupe_key: str | None
+
+
+@frozen
+class AudiencePage:
+ """One cursor-paginated page of a batch audience: person, group or account ids."""
+
+ ids: list[str]
+ has_more: bool
+
+
@frozen
class EmailSendingTierLimits:
"""What a trust tier allows: two send-rate caps and a maximum batch audience."""
diff --git a/products/workflows/backend/presentation/views/hog_flow.py b/products/workflows/backend/presentation/views/hog_flow.py
index dace48c2e4ea..e0a58615623e 100644
--- a/products/workflows/backend/presentation/views/hog_flow.py
+++ b/products/workflows/backend/presentation/views/hog_flow.py
@@ -103,8 +103,6 @@ from products.access_control.backend.presentation.access_control import (
AccessControlViewSetMixin,
UserAccessControlSerializerMixin,
)
-from products.feature_flags.backend.person_sampling import bounded_memory_settings
-from products.feature_flags.backend.user_blast_radius import BlastRadiusResult, get_user_blast_radius
from products.messaging.backend.api.design_operations import apply_design_operations
from products.messaging.backend.api.design_validation import validate_design
from products.messaging.backend.api.message_templates import DesignOperationSerializer
@@ -121,6 +119,16 @@ from products.tasks.backend.facade.workflow_tasks import (
validate_skill_names,
)
from products.workflows.backend.facade.api import create_batch_job
+from products.workflows.backend.facade.blast_radius import (
+ SUPPORTED_DEDUPE_KEYS,
+ get_account_audience_ids_page,
+ get_account_audience_size,
+ get_account_group_type_name,
+ get_audience_person_page,
+ get_audience_size,
+ is_account_audience,
+ parse_account_audience_filters,
+)
from products.workflows.backend.facade.secrets import (
TemplateCache,
mask_derived_trigger,
@@ -191,25 +199,6 @@ from products.workflows.backend.presentation.views.message_assets import (
)
from products.workflows.backend.presentation.views.publish_impact import build_publish_impact
from products.workflows.backend.providers.ses import SESProvider
-from products.workflows.backend.services.account_audience import (
- ACCOUNT_BATCH_SIZE,
- get_account_audience_count,
- get_account_audience_page,
- get_account_group_type_name,
- is_account_audience,
- parse_account_audience_filters,
-)
-from products.workflows.backend.services.audience_v2 import (
- get_dedupe_audience_count_v2,
- get_person_audience_count_v2,
- use_audience_query_v2,
-)
-from products.workflows.backend.services.batch_audience import (
- SUPPORTED_DEDUPE_KEYS,
- audience_page_size,
- get_batch_audience_count,
- get_batch_audience_person_ids,
-)
from products.workflows.backend.services.email_sending_attribution import (
EMAIL_HEALTH_METRIC_NAMES,
fold_email_totals_by_flow,
@@ -224,7 +213,6 @@ from products.workflows.backend.services.workflow_email_health import (
resume_workflow_email_sending,
)
from products.workflows.backend.tasks.hog_flows import reschedule_hog_flow_timing
-from products.workflows.backend.utils.batch_trigger_limit import get_hogflow_batch_trigger_limit
from products.workflows.backend.utils.email_sending_tiers import max_email_sending_tier, resolve_team_email_sending_tier
from products.workflows.backend.utils.rrule_utils import compute_next_occurrences, validate_rrule
@@ -932,6 +920,19 @@ class InternalBlastRadiusPersonsSerializer(serializers.Serializer):
has_more = serializers.BooleanField(help_text="Whether another page may follow.")
+class InternalAccountAudienceSerializer(serializers.Serializer):
+ """Response contract for the internal account audience endpoint, read by the Node batch resolver."""
+
+ accounts = serializers.ListField(
+ child=serializers.CharField(), help_text="Account group keys in this page, in stable pagination order."
+ )
+ cursor = serializers.CharField(
+ allow_null=True, help_text="Cursor for the next call, or null when this page is the last."
+ )
+ has_more = serializers.BooleanField(help_text="Whether another page may follow.")
+ group_type = serializers.CharField(allow_null=True, help_text="Group type the account keys belong to.")
+
+
class WorkflowGlobalStatsRequestSerializer(serializers.Serializer):
after = serializers.CharField(
required=False,
@@ -1441,7 +1442,7 @@ class HogFlowActionSerializer(serializers.Serializer):
)
if audience_type == "accounts":
team = self.context["get_team"]()
- if get_account_group_type_name(team) is None:
+ if get_account_group_type_name(team.id) is None:
raise serializers.ValidationError(
{
"filters": (
@@ -6120,12 +6121,13 @@ class HogFlowViewSet(
# data, so it requires the same access the audience editor requires.
if not self.user_access_control.check_access_level_for_resource("account", "viewer"):
raise exceptions.PermissionDenied("You do not have access to customer analytics accounts.")
+ size = get_account_audience_size(team_id=self.team_id, filters=filters, sends_email=params["sends_email"])
return Response(
BlastRadiusSerializer(
{
- "affected": get_account_audience_count(self.team, filters),
- "total": get_account_audience_count(self.team, {"audience_type": "accounts"}),
- "limit": get_hogflow_batch_trigger_limit(self.team_id, sends_email=params["sends_email"]),
+ "affected": size.affected,
+ "total": size.total,
+ "limit": size.limit,
"dedupe_key": None,
"confirm_token": mint_audience_confirm_token(self.team_id, filters, None, None),
}
@@ -6134,36 +6136,22 @@ class HogFlowViewSet(
reject_flag_conditions_in_audience(self.team, filters)
- # Preview matches the actual send: with dedup active, "affected" is the number of
- # sends (unique emails + email-less persons), not the number of matching persons —
- # the legacy person-count query is skipped entirely, "total" comes straight from
- # the cached team-wide count it would have returned anyway. The applied key is
- # echoed back so the frontend labels the count from the response instead of
- # guessing whether the dedup actually ran.
- applied_dedupe_key = None
- audience_v2 = group_type_index is None and use_audience_query_v2(self.team)
- if dedupe_key is not None and group_type_index is None:
- if audience_v2:
- blast_radius = get_dedupe_audience_count_v2(self.team, filters, dedupe_key)
- else:
- total = self.team.persons_seen_so_far
- affected = min(get_batch_audience_count(self.team, filters, dedupe_key), total)
- blast_radius = BlastRadiusResult(affected=affected, total=total)
- applied_dedupe_key = dedupe_key
- elif audience_v2:
- blast_radius = get_person_audience_count_v2(self.team, filters)
- else:
- blast_radius = get_user_blast_radius(self.team, filters, group_type_index)
-
+ size = get_audience_size(
+ team_id=self.team_id,
+ filters=filters,
+ group_type_index=group_type_index,
+ dedupe_key=dedupe_key,
+ sends_email=params["sends_email"],
+ )
return Response(
BlastRadiusSerializer(
{
- "affected": blast_radius.affected,
- "total": blast_radius.total,
- "limit": get_hogflow_batch_trigger_limit(self.team_id, sends_email=params["sends_email"]),
- "dedupe_key": applied_dedupe_key,
+ "affected": size.affected,
+ "total": size.total,
+ "limit": size.limit,
+ "dedupe_key": size.dedupe_key,
"confirm_token": mint_audience_confirm_token(
- self.team_id, filters, group_type_index, applied_dedupe_key
+ self.team_id, filters, group_type_index, size.dedupe_key
),
}
).data
@@ -6977,18 +6965,19 @@ class InternalHogFlowViewSet(TeamAndOrgViewSetMixin, LogEntryMixin, AppMetricsMi
try:
reject_flag_conditions_in_audience(team, filters)
- if group_type_index is None and use_audience_query_v2(team):
- result = get_person_audience_count_v2(team, filters)
- else:
- result = get_user_blast_radius(team, filters, group_type_index)
+ result = get_audience_size(
+ team_id=team.id,
+ filters=filters,
+ group_type_index=group_type_index,
+ dedupe_key=None,
+ sends_email=bool(request.data.get("sends_email", True)),
+ )
return Response(
BlastRadiusSerializer(
{
"affected": result.affected,
"total": result.total,
- "limit": get_hogflow_batch_trigger_limit(
- team.id, sends_email=bool(request.data.get("sends_email", True))
- ),
+ "limit": result.limit,
"dedupe_key": None,
}
).data
@@ -7025,18 +7014,19 @@ class InternalHogFlowViewSet(TeamAndOrgViewSetMixin, LogEntryMixin, AppMetricsMi
try:
reject_flag_conditions_in_audience(team, filters)
- enumeration_settings = (
- bounded_memory_settings() if group_type_index is None and use_audience_query_v2(team) else None
- )
- users_affected = get_batch_audience_person_ids(
- team, filters, group_type_index, cursor, dedupe_key=dedupe_key, settings=enumeration_settings
+ page = get_audience_person_page(
+ team_id=team.id,
+ filters=filters,
+ group_type_index=group_type_index,
+ cursor=cursor,
+ dedupe_key=dedupe_key,
)
return Response(
InternalBlastRadiusPersonsSerializer(
{
- "users_affected": users_affected,
- "cursor": users_affected[-1] if users_affected else None,
- "has_more": len(users_affected) == audience_page_size(group_type_index),
+ "users_affected": page.ids,
+ "cursor": page.ids[-1] if page.ids else None,
+ "has_more": page.has_more,
}
).data
)
@@ -7062,20 +7052,22 @@ class InternalHogFlowViewSet(TeamAndOrgViewSetMixin, LogEntryMixin, AppMetricsMi
filters = request.data.get("filters") or {}
if not is_account_audience(filters):
return Response({"error": "Filters must declare audience_type 'accounts'"}, status=400)
- group_type = get_account_group_type_name(team)
+ group_type = get_account_group_type_name(team.id)
if group_type is None:
return Response({"error": "No customer analytics account group type configured"}, status=400)
cursor = request.data.get("cursor")
try:
- accounts = get_account_audience_page(team, filters, cursor)
+ page = get_account_audience_ids_page(team_id=team.id, filters=filters, cursor=cursor)
return Response(
- {
- "accounts": accounts,
- "cursor": accounts[-1] if accounts else None,
- "has_more": len(accounts) == ACCOUNT_BATCH_SIZE,
- "group_type": group_type,
- }
+ InternalAccountAudienceSerializer(
+ {
+ "accounts": page.ids,
+ "cursor": page.ids[-1] if page.ids else None,
+ "has_more": page.has_more,
+ "group_type": group_type,
+ }
+ ).data
)
except exceptions.ValidationError as e:
return Response({"error": _validation_error_message(e)}, status=400)
diff --git a/products/workflows/backend/services/blast_radius.py b/products/workflows/backend/services/blast_radius.py
new file mode 100644
index 000000000000..bb9e19bf28a9
--- /dev/null
+++ b/products/workflows/backend/services/blast_radius.py
@@ -0,0 +1,101 @@
+"""Batch audience sizing and paging: the preview counts the editor shows, and the pages the Node
+batch resolver walks when it sends."""
+
+from posthog.models.property import GroupTypeIndex
+from posthog.models.team.team import Team
+
+from products.feature_flags.backend.person_sampling import bounded_memory_settings
+from products.feature_flags.backend.user_blast_radius import BlastRadiusResult, get_user_blast_radius
+from products.workflows.backend.facade.contracts import AudiencePage, AudienceSize
+from products.workflows.backend.services.account_audience import (
+ ACCOUNT_BATCH_SIZE,
+ get_account_audience_count,
+ get_account_audience_page,
+ get_account_group_type_name as _get_account_group_type_name,
+)
+from products.workflows.backend.services.audience_v2 import (
+ get_dedupe_audience_count_v2,
+ get_person_audience_count_v2,
+ use_audience_query_v2,
+)
+from products.workflows.backend.services.batch_audience import (
+ audience_page_size,
+ get_batch_audience_count,
+ get_batch_audience_person_ids,
+)
+from products.workflows.backend.utils.batch_trigger_limit import get_hogflow_batch_trigger_limit
+
+
+def get_audience_size(
+ *,
+ team_id: int,
+ filters: dict,
+ group_type_index: GroupTypeIndex | None,
+ dedupe_key: str | None,
+ sends_email: bool,
+) -> AudienceSize:
+ team = Team.objects.get(id=team_id)
+ # Preview matches the actual send: with dedup active, "affected" is the number of
+ # sends (unique emails + email-less persons), not the number of matching persons -
+ # the legacy person-count query is skipped entirely, "total" comes straight from
+ # the cached team-wide count it would have returned anyway. The applied key is
+ # echoed back so the frontend labels the count from the response instead of
+ # guessing whether the dedup actually ran.
+ applied_dedupe_key = None
+ audience_v2 = group_type_index is None and use_audience_query_v2(team)
+ if dedupe_key is not None and group_type_index is None:
+ if audience_v2:
+ blast_radius = get_dedupe_audience_count_v2(team, filters, dedupe_key)
+ else:
+ total = team.persons_seen_so_far
+ affected = min(get_batch_audience_count(team, filters, dedupe_key), total)
+ blast_radius = BlastRadiusResult(affected=affected, total=total)
+ applied_dedupe_key = dedupe_key
+ elif audience_v2:
+ blast_radius = get_person_audience_count_v2(team, filters)
+ else:
+ blast_radius = get_user_blast_radius(team, filters, group_type_index)
+
+ return AudienceSize(
+ affected=blast_radius.affected,
+ total=blast_radius.total,
+ limit=get_hogflow_batch_trigger_limit(team_id, sends_email=sends_email),
+ dedupe_key=applied_dedupe_key,
+ )
+
+
+def get_account_audience_size(*, team_id: int, filters: dict, sends_email: bool) -> AudienceSize:
+ team = Team.objects.get(id=team_id)
+ return AudienceSize(
+ affected=get_account_audience_count(team, filters),
+ total=get_account_audience_count(team, {"audience_type": "accounts"}),
+ limit=get_hogflow_batch_trigger_limit(team_id, sends_email=sends_email),
+ dedupe_key=None,
+ )
+
+
+def get_audience_person_page(
+ *,
+ team_id: int,
+ filters: dict,
+ group_type_index: GroupTypeIndex | None,
+ cursor: str | None,
+ dedupe_key: str | None,
+) -> AudiencePage:
+ team = Team.objects.get(id=team_id)
+ enumeration_settings = (
+ bounded_memory_settings() if group_type_index is None and use_audience_query_v2(team) else None
+ )
+ ids = get_batch_audience_person_ids(
+ team, filters, group_type_index, cursor, dedupe_key=dedupe_key, settings=enumeration_settings
+ )
+ return AudiencePage(ids=ids, has_more=len(ids) == audience_page_size(group_type_index))
+
+
+def get_account_audience_ids_page(*, team_id: int, filters: dict, cursor: str | None) -> AudiencePage:
+ ids = get_account_audience_page(Team.objects.get(id=team_id), filters, cursor)
+ return AudiencePage(ids=ids, has_more=len(ids) == ACCOUNT_BATCH_SIZE)
+
+
+def get_account_group_type_name(team_id: int) -> str | None:
+ return _get_account_group_type_name(Team.objects.get(id=team_id))
diff --git a/products/workflows/backend/tests/api/test_hog_flow.py b/products/workflows/backend/tests/api/test_hog_flow.py
index e2e65d216b51..80442901f253 100644
--- a/products/workflows/backend/tests/api/test_hog_flow.py
+++ b/products/workflows/backend/tests/api/test_hog_flow.py
@@ -3499,7 +3499,7 @@ class TestHogFlowAPI(APIBaseTest):
with (
self._account_audience_provider(),
patch(
- "products.workflows.backend.presentation.views.hog_flow.get_account_audience_page",
+ "products.workflows.backend.services.blast_radius.get_account_audience_page",
return_value=["a1", "a2"],
) as mock_page,
):
@@ -3559,7 +3559,7 @@ class TestHogFlowAPI(APIBaseTest):
with (
self._account_audience_provider(),
patch(
- "products.workflows.backend.presentation.views.hog_flow.get_account_audience_count", side_effect=[3, 10]
+ "products.workflows.backend.services.blast_radius.get_account_audience_count", side_effect=[3, 10]
) as mock_count,
):
response = self.client.post(
@@ -3727,7 +3727,7 @@ class TestHogFlowAPI(APIBaseTest):
def test_hog_flow_user_blast_radius_requires_filters(self):
with patch(
- "products.workflows.backend.presentation.views.hog_flow.get_user_blast_radius"
+ "products.workflows.backend.services.blast_radius.get_user_blast_radius"
) as mock_get_user_blast_radius:
response = self.client.post(f"/api/projects/{self.team.id}/hog_flows/user_blast_radius", {})
@@ -3737,7 +3737,7 @@ class TestHogFlowAPI(APIBaseTest):
def test_hog_flow_user_blast_radius_returns_counts(self):
with patch(
- "products.workflows.backend.presentation.views.hog_flow.get_user_blast_radius"
+ "products.workflows.backend.services.blast_radius.get_user_blast_radius"
) as mock_get_user_blast_radius:
from products.feature_flags.backend.user_blast_radius import BlastRadiusResult # noqa: PLC0415
@@ -3757,12 +3757,10 @@ class TestHogFlowAPI(APIBaseTest):
def test_hog_flow_user_blast_radius_routes_to_v2_when_flag_enabled(self):
with (
- patch("products.workflows.backend.presentation.views.hog_flow.use_audience_query_v2", return_value=True),
- patch("products.workflows.backend.presentation.views.hog_flow.get_person_audience_count_v2") as mock_v2,
- patch(
- "products.workflows.backend.presentation.views.hog_flow.get_dedupe_audience_count_v2"
- ) as mock_dedupe_v2,
- patch("products.workflows.backend.presentation.views.hog_flow.get_user_blast_radius") as mock_v1,
+ patch("products.workflows.backend.services.blast_radius.use_audience_query_v2", return_value=True),
+ patch("products.workflows.backend.services.blast_radius.get_person_audience_count_v2") as mock_v2,
+ patch("products.workflows.backend.services.blast_radius.get_dedupe_audience_count_v2") as mock_dedupe_v2,
+ patch("products.workflows.backend.services.blast_radius.get_user_blast_radius") as mock_v1,
):
from products.feature_flags.backend.user_blast_radius import BlastRadiusResult # noqa: PLC0415
@@ -3811,7 +3809,7 @@ class TestHogFlowAPI(APIBaseTest):
# sampled count here would move workflows numbers outside the workflows rollout.
# The routing test above mocks get_user_blast_radius away, so it cannot see this.
with (
- patch("products.workflows.backend.presentation.views.hog_flow.use_audience_query_v2", return_value=False),
+ patch("products.workflows.backend.services.blast_radius.use_audience_query_v2", return_value=False),
patch("products.feature_flags.backend.user_blast_radius.use_blast_radius_query_v2", return_value=True),
patch("products.feature_flags.backend.user_blast_radius.sampled_person_blast_radius") as mock_sampled,
):
@@ -3831,7 +3829,7 @@ class TestHogFlowAPI(APIBaseTest):
)
def test_hog_flow_user_blast_radius_returns_default_limit_for_unlisted_team(self):
with patch(
- "products.workflows.backend.presentation.views.hog_flow.get_user_blast_radius"
+ "products.workflows.backend.services.blast_radius.get_user_blast_radius"
) as mock_get_user_blast_radius:
from products.feature_flags.backend.user_blast_radius import BlastRadiusResult # noqa: PLC0415
@@ -3852,7 +3850,7 @@ class TestHogFlowAPI(APIBaseTest):
HOGFLOW_BATCH_TRIGGER_ELEVATED_TEAM_IDS={self.team.id},
),
patch(
- "products.workflows.backend.presentation.views.hog_flow.get_user_blast_radius"
+ "products.workflows.backend.services.blast_radius.get_user_blast_radius"
) as mock_get_user_blast_radius,
):
from products.feature_flags.backend.user_blast_radius import BlastRadiusResult # noqa: PLC0415
@@ -3890,7 +3888,7 @@ class TestHogFlowAPI(APIBaseTest):
scopes=["hog_flow:read", "person:read"],
)
with patch(
- "products.workflows.backend.presentation.views.hog_flow.get_user_blast_radius"
+ "products.workflows.backend.services.blast_radius.get_user_blast_radius"
) as mock_get_user_blast_radius:
from products.feature_flags.backend.user_blast_radius import BlastRadiusResult # noqa: PLC0415
@@ -3922,7 +3920,7 @@ class TestHogFlowAPI(APIBaseTest):
# Feature flags can't be sized as a static batch audience — reject with a clean 400 before
# the condition reaches the blast-radius query (where it would otherwise 500).
with patch(
- "products.workflows.backend.presentation.views.hog_flow.get_user_blast_radius"
+ "products.workflows.backend.services.blast_radius.get_user_blast_radius"
) as mock_get_user_blast_radius:
response = self.client.post(
f"/api/projects/{self.team.id}/hog_flows/user_blast_radius",
@@ -3936,7 +3934,7 @@ class TestHogFlowAPI(APIBaseTest):
@override_settings(INTERNAL_API_SECRET="test-secret-123")
def test_internal_user_blast_radius_rejects_flag_condition(self):
with patch(
- "products.workflows.backend.presentation.views.hog_flow.get_user_blast_radius"
+ "products.workflows.backend.services.blast_radius.get_user_blast_radius"
) as mock_get_user_blast_radius:
response = self.client.post(
f"/api/projects/{self.team.id}/internal/hog_flows/user_blast_radius",
@@ -3952,7 +3950,7 @@ class TestHogFlowAPI(APIBaseTest):
@override_settings(INTERNAL_API_SECRET="test-secret-123")
def test_internal_user_blast_radius_persons_rejects_flag_condition(self):
with patch(
- "products.workflows.backend.presentation.views.hog_flow.get_batch_audience_person_ids"
+ "products.workflows.backend.services.blast_radius.get_batch_audience_person_ids"
) as mock_get_batch_audience_person_ids:
response = self.client.post(
f"/api/projects/{self.team.id}/internal/hog_flows/user_blast_radius_persons",
@@ -3974,9 +3972,9 @@ class TestHogFlowAPI(APIBaseTest):
@override_settings(INTERNAL_API_SECRET="test-secret-123")
def test_internal_user_blast_radius_persons_uses_workflows_query(self, _name, gate_on, expected_timeout_mode):
with (
- patch("products.workflows.backend.presentation.views.hog_flow.use_audience_query_v2", return_value=gate_on),
+ patch("products.workflows.backend.services.blast_radius.use_audience_query_v2", return_value=gate_on),
patch(
- "products.workflows.backend.presentation.views.hog_flow.get_batch_audience_person_ids",
+ "products.workflows.backend.services.blast_radius.get_batch_audience_person_ids",
return_value=["id-1"],
) as mock_workflows_query,
):
@@ -4012,11 +4010,11 @@ class TestHogFlowAPI(APIBaseTest):
with (
patch(
- "products.workflows.backend.presentation.views.hog_flow.get_user_blast_radius",
+ "products.workflows.backend.services.blast_radius.get_user_blast_radius",
return_value=BlastRadiusResult(affected=5, total=10),
) as mock_legacy_count,
patch(
- "products.workflows.backend.presentation.views.hog_flow.get_batch_audience_count", return_value=3
+ "products.workflows.backend.services.blast_radius.get_batch_audience_count", return_value=3
) as mock_deduped_count,
patch(
"posthog.models.team.team.Team.persons_seen_so_far",
diff --git a/pyproject.toml b/pyproject.toml
index 33dbdc3fb654..73fc73ab94e3 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -735,8 +735,6 @@ ignore_imports = [
# parse -> facade -> serialize and delete each entry. backend:contract-check stays off until
# this list is empty. Only delete entries here: a new import from these views goes through
# the facade.
- "products.workflows.backend.presentation.views.hog_flow -> products.feature_flags.backend.person_sampling",
- "products.workflows.backend.presentation.views.hog_flow -> products.feature_flags.backend.user_blast_radius",
"products.workflows.backend.presentation.views.hog_flow -> products.messaging.backend.api.design_operations",
"products.workflows.backend.presentation.views.hog_flow -> products.messaging.backend.api.design_validation",
"products.workflows.backend.presentation.views.hog_flow -> products.messaging.backend.api.message_templates",
@@ -751,14 +749,10 @@ ignore_imports = [
"products.workflows.backend.presentation.views.hog_flow -> products.workflows.backend.models.team_workflows_config",
"products.workflows.backend.presentation.views.hog_flow -> products.workflows.backend.models.workflow_proposal",
"products.workflows.backend.presentation.views.hog_flow -> products.workflows.backend.providers.ses",
- "products.workflows.backend.presentation.views.hog_flow -> products.workflows.backend.services.account_audience",
- "products.workflows.backend.presentation.views.hog_flow -> products.workflows.backend.services.audience_v2",
- "products.workflows.backend.presentation.views.hog_flow -> products.workflows.backend.services.batch_audience",
"products.workflows.backend.presentation.views.hog_flow -> products.workflows.backend.services.email_sending_attribution",
"products.workflows.backend.presentation.views.hog_flow -> products.workflows.backend.services.timing_reschedule",
"products.workflows.backend.presentation.views.hog_flow -> products.workflows.backend.services.workflow_email_health",
"products.workflows.backend.presentation.views.hog_flow -> products.workflows.backend.tasks.hog_flows",
- "products.workflows.backend.presentation.views.hog_flow -> products.workflows.backend.utils.batch_trigger_limit",
"products.workflows.backend.presentation.views.hog_flow -> products.workflows.backend.utils.email_sending_tiers",
"products.workflows.backend.presentation.views.hog_flow -> products.workflows.backend.utils.rrule_utils",
# TODO: access-control presentation wave — the consolidated RBAC viewsets carry their ORM