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(analytics-platform): frozen dataclass returns and renames (#76130)

Arno Hillenb49099c7715a
diff --git a/ee/tasks/subscriptions/slack_subscriptions.py b/ee/tasks/subscriptions/slack_subscriptions.py
index 2a25dea37d48..95b3e9b73e8e 100644
--- a/ee/tasks/subscriptions/slack_subscriptions.py
+++ b/ee/tasks/subscriptions/slack_subscriptions.py
@@ -56,7 +56,7 @@ def _next_delivery_date_display(subscription: Subscription) -> str:
@dataclass
-class SlackMessageData:
+class SlackMessage:
channel: str
blocks: list[dict[str, Any]]
title: str
@@ -147,7 +147,7 @@ def _prepare_slack_message(
change_summary: str | None = None,
summary_skipped_over_budget: bool = False,
integration: Integration | None = None,
-) -> SlackMessageData:
+) -> SlackMessage:
"""Prepare Slack message content. Pure function with no side effects."""
utm_tags = f"{UTM_TAGS_BASE}&utm_medium=slack"
@@ -243,7 +243,7 @@ def _prepare_slack_message(
}
)
- return SlackMessageData(
+ return SlackMessage(
channel=channel,
blocks=blocks,
title=title,
@@ -325,9 +325,9 @@ async def _send_slack_message_with_retry(client, max_retries: int = 3, **kwargs)
async def deliver_slack_message_data(
integration: Integration,
subscription: Subscription,
- message_data: SlackMessageData,
+ message_data: SlackMessage,
) -> SlackDeliveryResult:
- # shared send path: callers build the SlackMessageData; retry + partial-failure handling are shared
+ # shared send path: callers build the SlackMessage; retry + partial-failure handling are shared
slack_integration = SlackIntegration(integration)
async with aiohttp.ClientSession(trust_env=True) as slack_session:
diff --git a/posthog/dags/sessions.py b/posthog/dags/sessions.py
index f620b01c7754..eb85338c454c 100644
--- a/posthog/dags/sessions.py
+++ b/posthog/dags/sessions.py
@@ -33,6 +33,7 @@ from posthog.clickhouse.cluster import get_cluster
from posthog.clickhouse.query_tagging import Feature, tags_context
from posthog.cloud_utils import is_cloud
from posthog.dags.common import JobOwners, dagster_tags
+from posthog.dataclasses import frozen
from posthog.git import get_git_commit_short
from posthog.models.raw_sessions.sessions_v3 import (
DISTRIBUTED_RAW_SESSIONS_TABLE_V3,
@@ -454,10 +455,18 @@ def _split_uint64_range(low: int, high: int, num: int, i: int) -> tuple[int, int
return sub_low, sub_high
+@frozen
+class ExperimentalChunking:
+ num_chunks: int
+ description: str
+ chunk_where_fn: Callable[[int], str]
+ sub_chunk_where_fn: Callable[[int, int, int], str]
+
+
def _get_experimental_chunking(
config: ExperimentalSessionsBackfillConfig,
-) -> tuple[int, str, Callable[[int], str], Callable[[int, int, int], str]]:
- """Return (num_chunks, description, chunk_where_fn, sub_chunk_where_fn) for the experimental backfill.
+) -> ExperimentalChunking:
+ """Return the chunking strategy for the experimental backfill.
chunk_where_fn(chunk_i) returns the chunk-level SQL condition.
sub_chunk_where_fn(parent_chunk_i, sub_chunk_i, total_sub_chunks) returns the chunk-level
@@ -505,7 +514,12 @@ def _get_experimental_chunking(
def team_sub_chunk(parent_chunk_i: int, sub_chunk_i: int, total_sub_chunks: int) -> str:
return f"({team_chunk(parent_chunk_i)}) AND ({full_range_sub_chunk(parent_chunk_i, sub_chunk_i, total_sub_chunks)})"
- return num_chunks, "team_id", team_chunk, team_sub_chunk
+ return ExperimentalChunking(
+ num_chunks=num_chunks,
+ description="team_id",
+ chunk_where_fn=team_chunk,
+ sub_chunk_where_fn=team_sub_chunk,
+ )
if has_distinct:
num_chunks = max(1, config.distinct_id_chunks or 1)
@@ -531,9 +545,19 @@ def _get_experimental_chunking(
is_last=parent_chunk_i == num_chunks - 1 and sub_chunk_i == total_sub_chunks - 1,
)
- return num_chunks, "cityHash64(distinct_id) range", distinct_id_chunk, distinct_id_sub_chunk
+ return ExperimentalChunking(
+ num_chunks=num_chunks,
+ description="cityHash64(distinct_id) range",
+ chunk_where_fn=distinct_id_chunk,
+ sub_chunk_where_fn=distinct_id_sub_chunk,
+ )
- return 1, "team_id", lambda i: "1", full_range_sub_chunk
+ return ExperimentalChunking(
+ num_chunks=1,
+ description="team_id",
+ chunk_where_fn=lambda i: "1",
+ sub_chunk_where_fn=full_range_sub_chunk,
+ )
def _is_oom_error(exc: Exception) -> bool:
@@ -686,7 +710,7 @@ def _do_experimental_backfill(
merged_settings.update(config.clickhouse_settings)
context.log.info(f"Using custom ClickHouse settings: {config.clickhouse_settings}")
- num_chunks, chunk_desc, chunk_where_fn, sub_chunk_where_fn = _get_experimental_chunking(config)
+ chunking = _get_experimental_chunking(config)
# Determine start chunk from Redis progress (unless force_fresh_restart is set)
asset_name = context.asset_key.path[-1]
@@ -699,18 +723,20 @@ def _do_experimental_backfill(
last_completed = _get_completed_chunk(asset_name, partition_key)
if last_completed is not None:
start_chunk = last_completed + 1
- context.log.info(f"Resuming from chunk {start_chunk}/{num_chunks} (last completed: {last_completed})")
+ context.log.info(
+ f"Resuming from chunk {start_chunk}/{chunking.num_chunks} (last completed: {last_completed})"
+ )
else:
start_chunk = 0
- if start_chunk >= num_chunks:
- context.log.info(f"All {num_chunks} chunks already completed, nothing to do")
+ if start_chunk >= chunking.num_chunks:
+ context.log.info(f"All {chunking.num_chunks} chunks already completed, nothing to do")
_clear_progress(asset_name, partition_key)
return
context.log.info(
f"Running backfill for Dagster partitions {partition_range_str} "
- f"(where='{where_clause}', chunking={num_chunks} chunks on {chunk_desc}, start_chunk={start_chunk}) "
+ f"(where='{where_clause}', chunking={chunking.num_chunks} chunks on {chunking.description}, start_chunk={start_chunk}) "
f"using commit {get_git_commit_short() or 'unknown'}"
)
if debug_url := metabase_debug_query_url(context.run_id):
@@ -724,21 +750,21 @@ def _do_experimental_backfill(
target_table = DISTRIBUTED_RAW_SESSIONS_TABLE_V3()
# Budget = num_chunks so a persistently un-merging partition fails fast instead of looping forever.
- parts_retry_state = {"count": 0, "max": num_chunks}
+ parts_retry_state = {"count": 0, "max": chunking.num_chunks}
with get_http_client(**kwargs, **config.client_overrides) as client:
tags = dagster_tags(context)
with tags_context(kind="dagster", dagster=tags, product=ProductKey.WEB_ANALYTICS, feature=Feature.BACKFILL):
- for chunk_i in range(start_chunk, num_chunks):
+ for chunk_i in range(start_chunk, chunking.num_chunks):
try:
wait_for_parts_to_merge(context, config, sync_client=client, table=target_table, use_cluster=False)
except Exception as e:
- _raise_failure(context, chunk_i, num_chunks, partition_range_str, e)
+ _raise_failure(context, chunk_i, chunking.num_chunks, partition_range_str, e)
- if num_chunks > 1:
- chunk_condition = chunk_where_fn(chunk_i)
+ if chunking.num_chunks > 1:
+ chunk_condition = chunking.chunk_where_fn(chunk_i)
chunk_where_clause = f"({where_clause}) AND {chunk_condition}"
- context.log.info(f"Processing chunk {chunk_i}/{num_chunks} ({chunk_condition})")
+ context.log.info(f"Processing chunk {chunk_i}/{chunking.num_chunks} ({chunk_condition})")
else:
chunk_where_clause = where_clause
@@ -758,14 +784,14 @@ def _do_experimental_backfill(
merged_settings,
target_table,
parts_retry_state,
- f"chunk {chunk_i}/{num_chunks}",
+ f"chunk {chunk_i}/{chunking.num_chunks}",
)
except Exception as e:
if not _is_oom_error(e):
- _raise_failure(context, chunk_i, num_chunks, partition_range_str, e)
+ _raise_failure(context, chunk_i, chunking.num_chunks, partition_range_str, e)
context.log.warning(
- f"OOM error on chunk {chunk_i}/{num_chunks}, "
+ f"OOM error on chunk {chunk_i}/{chunking.num_chunks}, "
f"retrying by splitting into {OOM_RETRY_SUB_CHUNKS} sub-chunks: {e}"
)
@@ -778,14 +804,14 @@ def _do_experimental_backfill(
_raise_failure(
context,
chunk_i,
- num_chunks,
+ chunking.num_chunks,
partition_range_str,
sub_e,
sub_chunk_i=sub_i,
total_sub_chunks=OOM_RETRY_SUB_CHUNKS,
)
- sub_chunk_condition = sub_chunk_where_fn(chunk_i, sub_i, OOM_RETRY_SUB_CHUNKS)
+ sub_chunk_condition = chunking.sub_chunk_where_fn(chunk_i, sub_i, OOM_RETRY_SUB_CHUNKS)
sub_where = f"({where_clause}) AND {sub_chunk_condition}"
sub_sql = sql_template(
where=sub_where,
@@ -793,7 +819,7 @@ def _do_experimental_backfill(
include_session_timestamp=True,
)
context.log.info(
- f"Running sub-chunk {sub_i}/{OOM_RETRY_SUB_CHUNKS} for chunk {chunk_i}/{num_chunks}"
+ f"Running sub-chunk {sub_i}/{OOM_RETRY_SUB_CHUNKS} for chunk {chunk_i}/{chunking.num_chunks}"
)
context.log.info(sub_sql)
try:
@@ -805,24 +831,24 @@ def _do_experimental_backfill(
merged_settings,
target_table,
parts_retry_state,
- f"chunk {chunk_i}/{num_chunks} sub-chunk {sub_i}/{OOM_RETRY_SUB_CHUNKS}",
+ f"chunk {chunk_i}/{chunking.num_chunks} sub-chunk {sub_i}/{OOM_RETRY_SUB_CHUNKS}",
)
except Exception as sub_e:
_raise_failure(
context,
chunk_i,
- num_chunks,
+ chunking.num_chunks,
partition_range_str,
sub_e,
sub_chunk_i=sub_i,
total_sub_chunks=OOM_RETRY_SUB_CHUNKS,
)
context.log.info(
- f"Completed sub-chunk {sub_i}/{OOM_RETRY_SUB_CHUNKS} for chunk {chunk_i}/{num_chunks}"
+ f"Completed sub-chunk {sub_i}/{OOM_RETRY_SUB_CHUNKS} for chunk {chunk_i}/{chunking.num_chunks}"
)
- if num_chunks > 1:
- context.log.info(f"Completed chunk {chunk_i}/{num_chunks}")
+ if chunking.num_chunks > 1:
+ context.log.info(f"Completed chunk {chunk_i}/{chunking.num_chunks}")
_save_completed_chunk(asset_name, partition_key, chunk_i)
diff --git a/posthog/dags/tests/test_sessions.py b/posthog/dags/tests/test_sessions.py
index 3eaf67535c36..0c8438755ff9 100644
--- a/posthog/dags/tests/test_sessions.py
+++ b/posthog/dags/tests/test_sessions.py
@@ -310,10 +310,10 @@ class TestSubChunking:
self, parent_i: int, all_have_upper_bound: bool, all_have_lower_bound: bool
):
config = ExperimentalSessionsBackfillConfig(distinct_id_chunks=4, client_overrides={})
- num_chunks, _, _, sub_chunk_where_fn = _get_experimental_chunking(config)
- assert num_chunks == 4
+ chunking = _get_experimental_chunking(config)
+ assert chunking.num_chunks == 4
- sub_filters = [sub_chunk_where_fn(parent_i, sub_i, 8) for sub_i in range(8)]
+ sub_filters = [chunking.sub_chunk_where_fn(parent_i, sub_i, 8) for sub_i in range(8)]
# Every sub-chunk filters cityHash64(distinct_id) — primary-index aligned
assert all("cityHash64(distinct_id)" in f for f in sub_filters)
@@ -326,12 +326,12 @@ class TestSubChunking:
def test_distinct_id_sub_chunks_cover_parent_range_without_gaps(self):
config = ExperimentalSessionsBackfillConfig(distinct_id_chunks=4, client_overrides={})
- _num_chunks, _, _, sub_chunk_where_fn = _get_experimental_chunking(config)
+ chunking = _get_experimental_chunking(config)
# Parent chunk 1 (middle) — bounded on both sides, easy to extract numbers
sub_bounds = []
for sub_i in range(8):
- f = sub_chunk_where_fn(1, sub_i, 8)
+ f = chunking.sub_chunk_where_fn(1, sub_i, 8)
# Filters look like "cityHash64(distinct_id) >= LOW AND cityHash64(distinct_id) < HIGH"
parts = f.replace("cityHash64(distinct_id)", "").replace("AND", "").split()
nums = [int(p) for p in parts if p.lstrip("-").isdigit()]
@@ -352,20 +352,20 @@ class TestSubChunking:
# team_id parent uses modulo (not primary-index-aligned), but sub-chunks should still split by
# cityHash64(distinct_id) ranges across the full uint64 space so the SELECT can skip granules.
config = ExperimentalSessionsBackfillConfig(team_id_chunks=3, distinct_id_chunks=None, client_overrides={})
- num_chunks, _, _, sub_chunk_where_fn = _get_experimental_chunking(config)
- assert num_chunks == 3
+ chunking = _get_experimental_chunking(config)
+ assert chunking.num_chunks == 3
- f = sub_chunk_where_fn(parent_i, sub_i, 4)
- assert f"team_id % {num_chunks} = {parent_i}" in f
+ f = chunking.sub_chunk_where_fn(parent_i, sub_i, 4)
+ assert f"team_id % {chunking.num_chunks} = {parent_i}" in f
assert "cityHash64(distinct_id)" in f
def test_no_chunk_sub_chunks_use_distinct_id_hash(self):
# No parent chunking — sub-chunks should still split by cityHash64(distinct_id) ranges
config = ExperimentalSessionsBackfillConfig(team_id_chunks=None, distinct_id_chunks=None, client_overrides={})
- num_chunks, _, _, sub_chunk_where_fn = _get_experimental_chunking(config)
- assert num_chunks == 1
+ chunking = _get_experimental_chunking(config)
+ assert chunking.num_chunks == 1
- sub_filters = [sub_chunk_where_fn(0, sub_i, 4) for sub_i in range(4)]
+ sub_filters = [chunking.sub_chunk_where_fn(0, sub_i, 4) for sub_i in range(4)]
assert all("cityHash64(distinct_id)" in f for f in sub_filters)
def test_oom_retry_executes_sub_chunks_within_parent_range(self):
diff --git a/products/analytics_platform/backend/lazy_computation/lazy_computation_executor.py b/products/analytics_platform/backend/lazy_computation/lazy_computation_executor.py
index a9f540598dbc..a9b5d5a6d220 100644
--- a/products/analytics_platform/backend/lazy_computation/lazy_computation_executor.py
+++ b/products/analytics_platform/backend/lazy_computation/lazy_computation_executor.py
@@ -515,7 +515,7 @@ def _get_ch_expires_at(job: "PreaggregationJob", table: LazyComputationTable) ->
@dataclass
-class QueryInfo:
+class LazyComputationQuery:
"""Normalized query information for lazy computation matching."""
query: ast.SelectQuery
@@ -540,9 +540,9 @@ class LazyComputationResult:
stale: bool = False
-def compute_query_hash(query_info: QueryInfo) -> str:
+def compute_query_hash(query_info: LazyComputationQuery) -> str:
"""
- Compute a stable hash for a QueryInfo object.
+ Compute a stable hash for a LazyComputationQuery object.
The hash is based on the normalized query structure and timezone.
"""
# Use repr() to get a deterministic string representation of the AST
@@ -832,7 +832,7 @@ def _written_rows(insert_result: object) -> int:
def run_lazy_computation_insert(
team: Team,
job: PreaggregationJob,
- query_info: QueryInfo,
+ query_info: LazyComputationQuery,
) -> int:
"""Run the INSERT query to populate lazy-computed results in ClickHouse.
@@ -923,7 +923,7 @@ class LazyComputationExecutor:
def execute(
self,
team: Team,
- query_info: QueryInfo,
+ query_info: LazyComputationQuery,
start: datetime,
end: datetime,
run_insert: Callable[[Team, PreaggregationJob], int | None] | None = None,
@@ -1438,7 +1438,7 @@ def ensure_precomputed(
}
parsed_for_hash = _resolve_insert_query(insert_query, hash_placeholders)
- query_info = QueryInfo(
+ query_info = LazyComputationQuery(
query=parsed_for_hash,
table=table,
timezone=team.timezone,
diff --git a/products/analytics_platform/backend/lazy_computation/lazy_computation_transformer.py b/products/analytics_platform/backend/lazy_computation/lazy_computation_transformer.py
index f3da2bff0888..5317ce025d4e 100644
--- a/products/analytics_platform/backend/lazy_computation/lazy_computation_transformer.py
+++ b/products/analytics_platform/backend/lazy_computation/lazy_computation_transformer.py
@@ -12,9 +12,9 @@ from posthog.models import Team
from products.analytics_platform.backend.lazy_computation.lazy_computation_executor import (
LazyComputationExecutor,
+ LazyComputationQuery,
LazyComputationResult,
LazyComputationTable,
- QueryInfo,
)
PREAGGREGATED_DAILY_UNIQUE_PERSONS_PAGEVIEWS_TABLE_NAME = DISTRIBUTED_PREAGGREGATION_RESULTS_TABLE()
@@ -463,11 +463,11 @@ def _run_daily_unique_persons_pageviews(
Orchestrate lazy computation jobs for daily unique persons pageviews.
This function:
- 1. Creates a QueryInfo object from the query
+ 1. Creates a LazyComputationQuery object from the query
2. Calls the executor to find/create lazy computation jobs
3. Returns the result with job IDs for the combiner query
"""
- query_info = QueryInfo(
+ query_info = LazyComputationQuery(
query=query_to_insert, table=LazyComputationTable.PREAGGREGATION_RESULTS, timezone=team.timezone
)
diff --git a/products/analytics_platform/backend/lazy_computation/tests/test_lazy_computation_executor.py b/products/analytics_platform/backend/lazy_computation/tests/test_lazy_computation_executor.py
index 0290f1d83eff..80e9ef370d4a 100644
--- a/products/analytics_platform/backend/lazy_computation/tests/test_lazy_computation_executor.py
+++ b/products/analytics_platform/backend/lazy_computation/tests/test_lazy_computation_executor.py
@@ -36,9 +36,9 @@ from products.analytics_platform.backend.lazy_computation.lazy_computation_execu
PREAGGREGATION_INSERT_QUORUM,
PREAGGREGATION_INSERT_QUORUM_TIMEOUT_MS,
LazyComputationExecutor,
+ LazyComputationQuery,
LazyComputationResult,
LazyComputationTable,
- QueryInfo,
TtlSchedule,
_build_manual_insert_sql,
_get_insert_settings,
@@ -106,8 +106,8 @@ class TestComputeQueryHash(BaseTest):
s2 = parse_select(q2)
assert isinstance(s1, ast.SelectQuery)
assert isinstance(s2, ast.SelectQuery)
- query_info1 = QueryInfo(query=s1, table=LazyComputationTable.PREAGGREGATION_RESULTS, timezone=t1)
- query_info2 = QueryInfo(query=s2, table=LazyComputationTable.PREAGGREGATION_RESULTS, timezone=t2)
+ query_info1 = LazyComputationQuery(query=s1, table=LazyComputationTable.PREAGGREGATION_RESULTS, timezone=t1)
+ query_info2 = LazyComputationQuery(query=s2, table=LazyComputationTable.PREAGGREGATION_RESULTS, timezone=t2)
hash1 = compute_query_hash(query_info1)
hash2 = compute_query_hash(query_info2)
@@ -486,7 +486,9 @@ class TestExecuteComputationJobs(ClickhouseTestMixin, BaseTest):
self._create_pageview_events()
query = self._make_computation_query()
- query_info = QueryInfo(query=query, table=LazyComputationTable.PREAGGREGATION_RESULTS, timezone="UTC")
+ query_info = LazyComputationQuery(
+ query=query, table=LazyComputationTable.PREAGGREGATION_RESULTS, timezone="UTC"
+ )
result = LazyComputationExecutor().execute(
team=self.team,
@@ -518,7 +520,9 @@ class TestExecuteComputationJobs(ClickhouseTestMixin, BaseTest):
self._create_pageview_events()
query = self._make_computation_query()
- query_info = QueryInfo(query=query, table=LazyComputationTable.PREAGGREGATION_RESULTS, timezone="UTC")
+ query_info = LazyComputationQuery(
+ query=query, table=LazyComputationTable.PREAGGREGATION_RESULTS, timezone="UTC"
+ )
# First: run for Jan 1-2
first_result = LazyComputationExecutor().execute(
@@ -563,7 +567,9 @@ class TestExecuteComputationJobs(ClickhouseTestMixin, BaseTest):
self._create_pageview_events()
query = self._make_computation_query()
- query_info = QueryInfo(query=query, table=LazyComputationTable.PREAGGREGATION_RESULTS, timezone="UTC")
+ query_info = LazyComputationQuery(
+ query=query, table=LazyComputationTable.PREAGGREGATION_RESULTS, timezone="UTC"
+ )
# First: Create job for Jan 2 only
jan2_result = LazyComputationExecutor().execute(
@@ -1432,7 +1438,9 @@ class TestRaceConditionHandling(BaseTest):
def test_integrity_error_on_create_loops_back_and_picks_up_pending_job(self):
query = self._make_computation_query()
- query_info = QueryInfo(query=query, table=LazyComputationTable.PREAGGREGATION_RESULTS, timezone="UTC")
+ query_info = LazyComputationQuery(
+ query=query, table=LazyComputationTable.PREAGGREGATION_RESULTS, timezone="UTC"
+ )
query_hash = compute_query_hash(query_info)
executor = LazyComputationExecutor(wait_timeout_seconds=2.0, poll_interval_seconds=0.05)
@@ -1495,7 +1503,9 @@ class TestRaceConditionHandling(BaseTest):
rather than a correctness bug.
"""
query = self._make_computation_query()
- query_info = QueryInfo(query=query, table=LazyComputationTable.PREAGGREGATION_RESULTS, timezone="UTC")
+ query_info = LazyComputationQuery(
+ query=query, table=LazyComputationTable.PREAGGREGATION_RESULTS, timezone="UTC"
+ )
query_hash = compute_query_hash(query_info)
range_a_start = datetime(2024, 1, 1, tzinfo=UTC)
@@ -1568,7 +1578,9 @@ class TestRaceConditionHandling(BaseTest):
def test_unique_constraint_prevents_duplicate_pending_jobs(self):
query = self._make_computation_query()
- query_info = QueryInfo(query=query, table=LazyComputationTable.PREAGGREGATION_RESULTS, timezone="UTC")
+ query_info = LazyComputationQuery(
+ query=query, table=LazyComputationTable.PREAGGREGATION_RESULTS, timezone="UTC"
+ )
query_hash = compute_query_hash(query_info)
# Create a PENDING job directly
@@ -1594,7 +1606,7 @@ class TestRaceConditionHandling(BaseTest):
class TestComputationExecutorExecute(BaseTest):
- def _make_query_info(self) -> tuple[QueryInfo, str]:
+ def _make_query_info(self) -> tuple[LazyComputationQuery, str]:
s = parse_select(
"""
SELECT
@@ -1607,7 +1619,7 @@ class TestComputationExecutorExecute(BaseTest):
"""
)
assert isinstance(s, ast.SelectQuery)
- qi = QueryInfo(query=s, table=LazyComputationTable.PREAGGREGATION_RESULTS, timezone="UTC")
+ qi = LazyComputationQuery(query=s, table=LazyComputationTable.PREAGGREGATION_RESULTS, timezone="UTC")
return qi, compute_query_hash(qi)
# --- Happy path ---
@@ -2672,7 +2684,9 @@ class TestPubsubAndStaleDetection(BaseTest):
"SELECT toStartOfDay(timestamp) as a, [] as b, uniqExactState(person_id) as c FROM events GROUP BY a"
)
assert isinstance(query, ast.SelectQuery)
- query_info = QueryInfo(query=query, table=LazyComputationTable.PREAGGREGATION_RESULTS, timezone="UTC")
+ query_info = LazyComputationQuery(
+ query=query, table=LazyComputationTable.PREAGGREGATION_RESULTS, timezone="UTC"
+ )
executor = LazyComputationExecutor()
result = executor.execute(
@@ -2694,7 +2708,9 @@ class TestPubsubAndStaleDetection(BaseTest):
"SELECT toStartOfDay(timestamp) as a, [] as b, uniqExactState(person_id) as c FROM events GROUP BY a"
)
assert isinstance(query, ast.SelectQuery)
- query_info = QueryInfo(query=query, table=LazyComputationTable.PREAGGREGATION_RESULTS, timezone="UTC")
+ query_info = LazyComputationQuery(
+ query=query, table=LazyComputationTable.PREAGGREGATION_RESULTS, timezone="UTC"
+ )
executor = LazyComputationExecutor(max_retries=0)
result = executor.execute(
@@ -2735,12 +2751,12 @@ class TestJobLifecycleCounters(BaseTest):
TABLE = LazyComputationTable.PREAGGREGATION_RESULTS
- def _query_info(self) -> QueryInfo:
+ def _query_info(self) -> LazyComputationQuery:
query = parse_select(
"SELECT toStartOfDay(timestamp) as a, [] as b, uniqExactState(person_id) as c FROM events GROUP BY a"
)
assert isinstance(query, ast.SelectQuery)
- return QueryInfo(query=query, table=self.TABLE, timezone="UTC")
+ return LazyComputationQuery(query=query, table=self.TABLE, timezone="UTC")
@staticmethod
def _delta(metric, labels: dict[str, str], before: float) -> float:
@@ -3092,7 +3108,7 @@ class TestInsertSettingsAppliedToInserts(BaseTest):
},
)
assert isinstance(query, ast.SelectQuery)
- query_info = QueryInfo(query=query, table=LazyComputationTable.PREAGGREGATION_RESULTS)
+ query_info = LazyComputationQuery(query=query, table=LazyComputationTable.PREAGGREGATION_RESULTS)
with patch(
"products.analytics_platform.backend.lazy_computation.lazy_computation_executor.sync_execute"
@@ -3123,7 +3139,7 @@ class TestInsertsReportRowsWritten(BaseTest):
expires_at=django_timezone.now() + timedelta(days=7),
)
- def _query_info(self) -> QueryInfo:
+ def _query_info(self) -> LazyComputationQuery:
query = parse_select(
self.INSERT_QUERY,
placeholders={
@@ -3132,7 +3148,7 @@ class TestInsertsReportRowsWritten(BaseTest):
},
)
assert isinstance(query, ast.SelectQuery)
- return QueryInfo(query=query, table=LazyComputationTable.PREAGGREGATION_RESULTS)
+ return LazyComputationQuery(query=query, table=LazyComputationTable.PREAGGREGATION_RESULTS)
@parameterized.expand([("productive", 42, 42), ("empty_passthrough", [], 0), ("empty_none", None, 0)])
def test_ast_insert_returns_rows_written(self, _name, sync_execute_result, expected):
@@ -3194,7 +3210,7 @@ class TestMaxWindowDaysCap(BaseTest):
class TestExecuteOOMAndBudget(ClickhouseTestMixin, BaseTest):
- def _query_info(self) -> QueryInfo:
+ def _query_info(self) -> LazyComputationQuery:
s = parse_select(
"""
SELECT toStartOfDay(timestamp) as time_window_start, [] as breakdown_value,
@@ -3203,7 +3219,7 @@ class TestExecuteOOMAndBudget(ClickhouseTestMixin, BaseTest):
"""
)
assert isinstance(s, ast.SelectQuery)
- return QueryInfo(query=s, table=LazyComputationTable.PREAGGREGATION_RESULTS, timezone="UTC")
+ return LazyComputationQuery(query=s, table=LazyComputationTable.PREAGGREGATION_RESULTS, timezone="UTC")
def test_surfaces_memory_exceeded_on_oom(self):
def oom_insert(_t, _j) -> None:
@@ -3280,7 +3296,9 @@ class TestCheckOnlyMode(BaseTest):
def _execute(self, start: datetime, end: datetime) -> LazyComputationResult:
query = parse_select("SELECT 1")
assert isinstance(query, ast.SelectQuery)
- query_info = QueryInfo(query=query, table=LazyComputationTable.PREAGGREGATION_RESULTS, timezone="UTC")
+ query_info = LazyComputationQuery(
+ query=query, table=LazyComputationTable.PREAGGREGATION_RESULTS, timezone="UTC"
+ )
def forbidden_insert(team, job):
raise AssertionError("check-only mode must never run inserts")
@@ -3299,7 +3317,7 @@ class TestCheckOnlyMode(BaseTest):
return PreaggregationJob.objects.create(
team=self.team,
query_hash=compute_query_hash(
- QueryInfo(query=query, table=LazyComputationTable.PREAGGREGATION_RESULTS, timezone="UTC")
+ LazyComputationQuery(query=query, table=LazyComputationTable.PREAGGREGATION_RESULTS, timezone="UTC")
),
time_range_start=start,
time_range_end=end,
diff --git a/products/dashboards/backend/api/dashboard.py b/products/dashboards/backend/api/dashboard.py
index 1084f1a81743..c8dab626b45d 100644
--- a/products/dashboards/backend/api/dashboard.py
+++ b/products/dashboards/backend/api/dashboard.py
@@ -429,14 +429,23 @@ DEFAULT_REORDER_TILE_WIDTH = 6
DEFAULT_REORDER_TILE_HEIGHT = 5
-def _existing_sm_size(tile: DashboardTile, default_w: int, default_h: int) -> tuple[int, int]:
+@frozen
+class TileSize:
+ width: int
+ height: int
+
+
+DEFAULT_REORDER_TILE_SIZE = TileSize(width=DEFAULT_REORDER_TILE_WIDTH, height=DEFAULT_REORDER_TILE_HEIGHT)
+
+
+def _existing_sm_size(tile: DashboardTile, defaults: TileSize) -> TileSize:
sm = (tile.layouts or {}).get("sm") if isinstance(tile.layouts, dict) else None
if not isinstance(sm, dict):
- return default_w, default_h
+ return defaults
w, h = sm.get("w"), sm.get("h")
- return (
- w if isinstance(w, int) and w > 0 else default_w,
- h if isinstance(h, int) and h > 0 else default_h,
+ return TileSize(
+ width=w if isinstance(w, int) and w > 0 else defaults.width,
+ height=h if isinstance(h, int) and h > 0 else defaults.height,
)
@@ -474,9 +483,9 @@ def _apply_reorder_layout(
xs_y = 0
for tile_id in tile_order:
tile = tile_map[tile_id]
- existing_w, existing_h = _existing_sm_size(tile, DEFAULT_REORDER_TILE_WIDTH, DEFAULT_REORDER_TILE_HEIGHT)
- w = max(1, min(existing_w, DASHBOARD_GRID_COLUMN_COUNT))
- h = max(1, existing_h)
+ size = _existing_sm_size(tile, DEFAULT_REORDER_TILE_SIZE)
+ w = max(1, min(size.width, DASHBOARD_GRID_COLUMN_COUNT))
+ h = max(1, size.height)
# x=0 is the baseline candidate; scan the remaining start positions for a lower segment top,
# keeping the leftmost on ties (the loop only updates on a strictly lower top).
diff --git a/products/exports/backend/models/subscription.py b/products/exports/backend/models/subscription.py
index 3cc078204f71..304557693b89 100644
--- a/products/exports/backend/models/subscription.py
+++ b/products/exports/backend/models/subscription.py
@@ -88,7 +88,7 @@ WEEKDAY_SET = {"monday", "tuesday", "wednesday", "thursday", "friday"}
@dataclass
-class SubscriptionResourceInfo:
+class SubscriptionResource:
kind: str
name: str
url: str
@@ -416,21 +416,21 @@ class Subscription(ModelActivityMixin, models.Model):
return None
@property
- def resource_info(self) -> Optional[SubscriptionResourceInfo]:
+ def resource_info(self) -> Optional[SubscriptionResource]:
if not self._has_resource:
return None
match self.resource_type:
case self.ResourceType.INSIGHT if self.insight:
- return SubscriptionResourceInfo(
+ return SubscriptionResource(
"Insight",
f"{self.insight.name or self.insight.derived_name}",
self.insight.url,
)
case self.ResourceType.DASHBOARD if self.dashboard:
- return SubscriptionResourceInfo("Dashboard", self.dashboard.name or "Dashboard", self.dashboard.url)
+ return SubscriptionResource("Dashboard", self.dashboard.name or "Dashboard", self.dashboard.url)
case self.ResourceType.AI_PROMPT:
ai_name = self.title or (self.prompt or "").strip()[:AI_PROMPT_DISPLAY_MAX_LEN] or "AI report"
- return SubscriptionResourceInfo("AI", ai_name, self.url or "")
+ return SubscriptionResource("AI", ai_name, self.url or "")
return None
@property
diff --git a/products/exports/backend/temporal/subscriptions/activities.py b/products/exports/backend/temporal/subscriptions/activities.py
index 8bf0793a272d..cd3277d7513e 100644
--- a/products/exports/backend/temporal/subscriptions/activities.py
+++ b/products/exports/backend/temporal/subscriptions/activities.py
@@ -33,13 +33,13 @@ from products.exports.backend.temporal.subscriptions.types import (
CreateExportAssetsResult,
DeliverSubscriptionInputs,
DeliverSubscriptionResult,
+ DeliveryAbort,
+ DueSubscription,
ExportAssetPreparationStatus,
FetchDueSubscriptionsActivityInputs,
NoExportableInsightsContext,
NoExportableInsightsReason,
RecipientResult,
- SubscriptionAbortInfo,
- SubscriptionInfo,
UpdateDeliveryRecordInputs,
)
from products.product_analytics.backend.models.insight import Insight
@@ -184,14 +184,14 @@ async def _persist_content_snapshot(
@temporalio.activity.defn
-async def fetch_due_subscriptions_activity(inputs: FetchDueSubscriptionsActivityInputs) -> list[SubscriptionInfo]:
+async def fetch_due_subscriptions_activity(inputs: FetchDueSubscriptionsActivityInputs) -> list[DueSubscription]:
now_with_buffer = dt.datetime.now(dt.UTC) + dt.timedelta(minutes=inputs.buffer_minutes)
await LOGGER.ainfo("Fetching due subscriptions", deadline=now_with_buffer)
@database_sync_to_async(thread_sensitive=False)
- def get_subscriptions() -> list[SubscriptionInfo]:
+ def get_subscriptions() -> list[DueSubscription]:
return [
- SubscriptionInfo(
+ DueSubscription(
subscription_id=sub["id"],
team_id=sub["team_id"],
distinct_id=str(sub["created_by__distinct_id"])
@@ -219,7 +219,7 @@ async def fetch_due_subscriptions_activity(inputs: FetchDueSubscriptionsActivity
@temporalio.activity.defn
-async def validate_subscription_for_delivery(subscription_id: int) -> SubscriptionAbortInfo | None:
+async def validate_subscription_for_delivery(subscription_id: int) -> DeliveryAbort | None:
"""Returns abort info when delivery should not proceed; None to continue."""
subscription = await database_sync_to_async(
Subscription.objects.select_related("created_by", "integration").get,
@@ -230,7 +230,7 @@ async def validate_subscription_for_delivery(subscription_id: int) -> Subscripti
# prior auto-disable committed must not re-fire side effects.
if not subscription.enabled:
await LOGGER.ainfo("validate_subscription.already_disabled_skipping", subscription_id=subscription_id)
- return SubscriptionAbortInfo()
+ return DeliveryAbort()
reason = get_subscription_disable_reason(subscription.target_type, subscription.integration_id)
if reason is None:
@@ -244,7 +244,7 @@ async def validate_subscription_for_delivery(subscription_id: int) -> Subscripti
)
_capture_delivery_failed_event(subscription, Exception(reason.description))
await database_sync_to_async(disable_invalid_subscription, thread_sensitive=False)(subscription, reason)
- return SubscriptionAbortInfo(
+ return DeliveryAbort(
failed_recipient=RecipientResult(
recipient=subscription.target_value,
status="failed",
diff --git a/products/exports/backend/temporal/subscriptions/ai_subscription/activities.py b/products/exports/backend/temporal/subscriptions/ai_subscription/activities.py
index a772dfd1881b..31b4ab0d8db4 100644
--- a/products/exports/backend/temporal/subscriptions/ai_subscription/activities.py
+++ b/products/exports/backend/temporal/subscriptions/ai_subscription/activities.py
@@ -11,6 +11,7 @@ from asgiref.sync import sync_to_async
from structlog import get_logger
from temporalio.exceptions import ApplicationError
+from posthog.dataclasses import frozen
from posthog.models import OrganizationMembership
from posthog.ph_client import ph_scoped_capture
from posthog.sync import database_sync_to_async
@@ -76,19 +77,26 @@ async def _load_ai_report(delivery_id: uuid.UUID) -> str | None:
return _snapshot_report(await _load_snapshot(delivery_id))
-def _tally_diagnostics(steps: list[tuple[bool, str | None]]) -> tuple[int, int, list[str]]:
- # (failed_step_count, total_step_count, sorted distinct failure types) from (ok, error_type)
+@frozen
+class DiagnosticCounts:
+ failed_step_count: int
+ total_step_count: int
+ error_types: list[str]
+
+
+def _tally_diagnostics(steps: list[tuple[bool, str | None]]) -> DiagnosticCounts:
+ # Failed/total step counts plus sorted distinct failure types from (ok, error_type)
# pairs — shared by the persisted-snapshot and in-memory diagnostic paths.
failed = [error_type for ok, error_type in steps if not ok]
error_types = sorted({str(error_type) for error_type in failed if error_type})
- return (len(failed), len(steps), error_types)
+ return DiagnosticCounts(failed_step_count=len(failed), total_step_count=len(steps), error_types=error_types)
-def _snapshot_diagnostic_counts(snapshot: dict | None) -> tuple[int, int, list[str]]:
+def _snapshot_diagnostic_counts(snapshot: dict | None) -> DiagnosticCounts:
# The prior run's failure shape, read back from the persisted diagnostics on Temporal redispatch.
diagnostics = snapshot.get(AI_REPORT_DIAGNOSTICS_KEY) if snapshot else None
if not isinstance(diagnostics, list):
- return (0, 0, [])
+ return DiagnosticCounts(failed_step_count=0, total_step_count=0, error_types=[])
# Only well-formed dict entries count — a malformed one would inflate the total and mask an
# all-failed report; `ok is not False` keeps a missing/None ok out of the failed set.
return _tally_diagnostics(
@@ -96,7 +104,7 @@ def _snapshot_diagnostic_counts(snapshot: dict | None) -> tuple[int, int, list[s
)
-def _report_diagnostic_counts(result: AiReportResult) -> tuple[int, int, list[str]]:
+def _report_diagnostic_counts(result: AiReportResult) -> DiagnosticCounts:
return _tally_diagnostics([(d.ok, d.error_type) for d in result.diagnostics])
@@ -217,12 +225,12 @@ async def generate_ai_subscription_report(inputs: GenerateAIReportInputs) -> Gen
snapshot = await _load_snapshot(inputs.delivery_id)
if _snapshot_report(snapshot) is not None:
await LOGGER.ainfo("generate_ai_subscription_report.already_generated", subscription_id=subscription.id)
- failed_count, total_count, error_types = _snapshot_diagnostic_counts(snapshot)
+ counts = _snapshot_diagnostic_counts(snapshot)
return GenerateAIReportResult(
aborted=False,
- failed_step_count=failed_count,
- total_step_count=total_count,
- query_error_types=error_types,
+ failed_step_count=counts.failed_step_count,
+ total_step_count=counts.total_step_count,
+ query_error_types=counts.error_types,
target_type=subscription.target_type,
)
@@ -301,12 +309,12 @@ async def generate_ai_subscription_report(inputs: GenerateAIReportInputs) -> Gen
)
await _persist_ai_report(inputs.delivery_id, report_result, subscription.prompt)
- failed_count, total_count, error_types = _report_diagnostic_counts(report_result)
+ counts = _report_diagnostic_counts(report_result)
return GenerateAIReportResult(
aborted=False,
- failed_step_count=failed_count,
- total_step_count=total_count,
- query_error_types=error_types,
+ failed_step_count=counts.failed_step_count,
+ total_step_count=counts.total_step_count,
+ query_error_types=counts.error_types,
target_type=subscription.target_type,
)
diff --git a/products/exports/backend/temporal/subscriptions/ai_subscription/delivery.py b/products/exports/backend/temporal/subscriptions/ai_subscription/delivery.py
index c9c149f6e446..40fe19f45f0d 100644
--- a/products/exports/backend/temporal/subscriptions/ai_subscription/delivery.py
+++ b/products/exports/backend/temporal/subscriptions/ai_subscription/delivery.py
@@ -31,7 +31,7 @@ from products.exports.backend.temporal.subscriptions.types import AI_REPORT_WIND
from ee.tasks.subscriptions.slack_subscriptions import (
UTM_TAGS_BASE,
SlackDeliveryResult,
- SlackMessageData,
+ SlackMessage,
deliver_slack_message_data,
)
@@ -297,7 +297,7 @@ def _build_ai_slack_message(
*,
delivery_id: uuid.UUID,
integration: Integration | None = None,
-) -> SlackMessageData:
+) -> SlackMessage:
utm_tags = f"{UTM_TAGS_BASE}&utm_medium=slack"
channel = subscription.target_value.split("|")[0]
sections = _split_text_into_chunks(_SLACK_CONVERTER.convert(strip_external_links_markdown(markdown)))
@@ -352,7 +352,7 @@ def _build_ai_slack_message(
{"blocks": [{"type": "section", "text": {"type": "mrkdwn", "text": section}}]} for section in sections[1:]
]
# unfurl=False: report content is LLM-generated; never let Slack auto-fetch a link it contains.
- return SlackMessageData(channel=channel, blocks=blocks, title=title, thread_messages=thread_messages, unfurl=False)
+ return SlackMessage(channel=channel, blocks=blocks, title=title, thread_messages=thread_messages, unfurl=False)
async def send_slack_ai_subscription_report(
diff --git a/products/exports/backend/temporal/subscriptions/ai_subscription/test/test_activities.py b/products/exports/backend/temporal/subscriptions/ai_subscription/test/test_activities.py
index 45ca44dd74a4..90576f162d6a 100644
--- a/products/exports/backend/temporal/subscriptions/ai_subscription/test/test_activities.py
+++ b/products/exports/backend/temporal/subscriptions/ai_subscription/test/test_activities.py
@@ -8,6 +8,7 @@ from parameterized import parameterized
from products.exports.backend.models.subscription import Subscription, SubscriptionDelivery
from products.exports.backend.temporal.subscriptions.ai_subscription.activities import (
+ DiagnosticCounts,
_load_snapshot,
_persist_ai_report,
_report_diagnostic_counts,
@@ -160,7 +161,9 @@ class TestReportDiagnosticCounts:
for i, ok in enumerate(oks)
),
)
- assert _report_diagnostic_counts(result) == (expected_failed, expected_total, expected_types)
+ assert _report_diagnostic_counts(result) == DiagnosticCounts(
+ failed_step_count=expected_failed, total_step_count=expected_total, error_types=expected_types
+ )
def test_distinct_error_types_are_sorted_and_deduped(self):
result = AiReportResult(
@@ -172,7 +175,9 @@ class TestReportDiagnosticCounts:
QueryStepDiagnostic(description="c", hogql="z", ok=False, error_type="ResolutionError"),
),
)
- assert _report_diagnostic_counts(result) == (3, 3, ["ExposedHogQLError", "ResolutionError"])
+ assert _report_diagnostic_counts(result) == DiagnosticCounts(
+ failed_step_count=3, total_step_count=3, error_types=["ExposedHogQLError", "ResolutionError"]
+ )
# On Temporal redispatch the report is already persisted, so the failure shape is read back from the
@@ -192,11 +197,14 @@ async def test_snapshot_diagnostic_counts_reads_persisted_failure_shape(team, us
prompt=None,
)
- assert _snapshot_diagnostic_counts(await _load_snapshot(delivery.id)) == (1, 2, ["ResolutionError"])
+ assert _snapshot_diagnostic_counts(await _load_snapshot(delivery.id)) == DiagnosticCounts(
+ failed_step_count=1, total_step_count=2, error_types=["ResolutionError"]
+ )
async def test_snapshot_diagnostic_counts_handles_missing_diagnostics(team, user) -> None:
delivery = await _create_delivery(team, user)
# Empty content_snapshot (nothing persisted yet) and a fully-missing snapshot both report nothing failed.
- assert _snapshot_diagnostic_counts(await _load_snapshot(delivery.id)) == (0, 0, [])
- assert _snapshot_diagnostic_counts(None) == (0, 0, [])
+ empty_counts = DiagnosticCounts(failed_step_count=0, total_step_count=0, error_types=[])
+ assert _snapshot_diagnostic_counts(await _load_snapshot(delivery.id)) == empty_counts
+ assert _snapshot_diagnostic_counts(None) == empty_counts
diff --git a/products/exports/backend/temporal/subscriptions/ai_subscription/test/test_delivery.py b/products/exports/backend/temporal/subscriptions/ai_subscription/test/test_delivery.py
index 6706ef3dd251..14cc06b85e2b 100644
--- a/products/exports/backend/temporal/subscriptions/ai_subscription/test/test_delivery.py
+++ b/products/exports/backend/temporal/subscriptions/ai_subscription/test/test_delivery.py
@@ -24,7 +24,7 @@ from products.exports.backend.temporal.subscriptions.ai_subscription.report_pipe
from products.exports.backend.temporal.subscriptions.ai_subscription.spec_generator import ReportWindow
from products.exports.backend.temporal.subscriptions.types import AI_REPORT_WINDOW_END_KEY, SubscriptionTriggerType
-from ee.tasks.subscriptions.slack_subscriptions import SlackMessageData
+from ee.tasks.subscriptions.slack_subscriptions import SlackMessage
_DELIVERY = "products.exports.backend.temporal.subscriptions.ai_subscription.delivery"
@@ -196,7 +196,7 @@ def _mock_subscription() -> MagicMock:
return sub
-def _build_message(markdown: str) -> SlackMessageData:
+def _build_message(markdown: str) -> SlackMessage:
return _build_ai_slack_message(_mock_subscription(), markdown, delivery_id=_DELIVERY_ID)
@@ -226,11 +226,11 @@ def _mock_integration(scopes: frozenset[str]) -> MagicMock:
return integration
-def _hint_texts(message: SlackMessageData) -> list[str]:
+def _hint_texts(message: SlackMessage) -> list[str]:
return [el["text"] for block in message.blocks if block.get("type") == "context" for el in block["elements"]]
-def _ai_message(*, integration: MagicMock | None = None) -> SlackMessageData:
+def _ai_message(*, integration: MagicMock | None = None) -> SlackMessage:
return _build_ai_slack_message(
_mock_subscription(),
"A short report.",
diff --git a/products/exports/backend/temporal/subscriptions/types.py b/products/exports/backend/temporal/subscriptions/types.py
index de79b9f322a5..c0159939a769 100644
--- a/products/exports/backend/temporal/subscriptions/types.py
+++ b/products/exports/backend/temporal/subscriptions/types.py
@@ -120,7 +120,7 @@ class SubscriptionTriggerType:
@dataclasses.dataclass
-class SubscriptionInfo:
+class DueSubscription:
subscription_id: int
team_id: int
distinct_id: str
@@ -306,7 +306,7 @@ class GenerateAIReportResult:
@dataclasses.dataclass
-class SubscriptionAbortInfo:
+class DeliveryAbort:
"""Returned by `validate_subscription_for_delivery` when the workflow should abort.
`failed_recipient` is populated only when this run auto-disabled the sub
(workflow records FAILED). None means already-disabled — idempotency redispatch."""
diff --git a/products/exports/backend/temporal/subscriptions/workflows.py b/products/exports/backend/temporal/subscriptions/workflows.py
index 034106b64560..a1e5c6dad871 100644
--- a/products/exports/backend/temporal/subscriptions/workflows.py
+++ b/products/exports/backend/temporal/subscriptions/workflows.py
@@ -47,6 +47,7 @@ from products.exports.backend.temporal.subscriptions.types import (
DeliverSubscriptionInputs,
DeliverSubscriptionResult,
DeliveryStatus,
+ DueSubscription,
ExportAssetPreparationStatus,
FetchDueSubscriptionsActivityInputs,
GenerateAIReportInputs,
@@ -55,7 +56,6 @@ from products.exports.backend.temporal.subscriptions.types import (
RecipientResult,
ScheduleAllSubscriptionsWorkflowInputs,
SnapshotInsightsInputs,
- SubscriptionInfo,
SubscriptionTriggerType,
TrackedSubscriptionInputs,
UpdateDeliveryRecordInputs,
@@ -115,7 +115,7 @@ class ScheduleAllSubscriptionsWorkflow(PostHogWorkflow):
@temporalio.workflow.run
async def run(self, inputs: ScheduleAllSubscriptionsWorkflowInputs) -> None:
fetch_inputs = FetchDueSubscriptionsActivityInputs(buffer_minutes=inputs.buffer_minutes)
- subscription_infos: list[SubscriptionInfo] = await temporalio.workflow.execute_activity(
+ subscription_infos: list[DueSubscription] = await temporalio.workflow.execute_activity(
fetch_due_subscriptions_activity,
fetch_inputs,
start_to_close_timeout=dt.timedelta(minutes=5),