Skip to content

Commit 4fd9867

Browse files
committed
chore(aci): Remove uses if is_single_written flag
1 parent 24794d5 commit 4fd9867

File tree

11 files changed

+11
-71
lines changed

11 files changed

+11
-71
lines changed

src/sentry/api/serializers/models/rule.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,7 @@ def get_attrs(self, item_list, user, **kwargs):
222222
)
223223

224224
workflow_fire_results = (
225-
WorkflowFireHistory.objects.filter(
226-
workflow_id__in=workflow_rule_lookup.keys(), is_single_written=True
227-
)
225+
WorkflowFireHistory.objects.filter(workflow_id__in=workflow_rule_lookup.keys())
228226
.values("workflow_id")
229227
.annotate(date_added=Max("date_added"))
230228
)

src/sentry/rules/history/backends/postgres.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def data_fn(offset: int, limit: int) -> list[_Result]:
8686
UNION ALL
8787
SELECT group_id, date_added, event_id
8888
FROM workflow_engine_workflowfirehistory
89-
WHERE workflow_id = %s AND is_single_written = true
89+
WHERE workflow_id = %s
9090
AND date_added >= %s AND date_added < %s
9191
)
9292
SELECT
@@ -180,7 +180,6 @@ def fetch_rule_hourly_stats(
180180
SELECT date_added
181181
FROM workflow_engine_workflowfirehistory
182182
WHERE workflow_id = %s
183-
AND is_single_written = true
184183
AND date_added >= %s
185184
AND date_added < %s
186185
) combined_data

src/sentry/workflow_engine/endpoints/organization_workflow_index.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,7 @@ def get(self, request, organization):
198198
# to be more efficient than a Max() aggregation, because it lets us look at ~1
199199
# workflow fire history row per workflow.
200200
latest_fire_subquery = Subquery(
201-
WorkflowFireHistory.objects.filter(
202-
workflow=OuterRef("pk"), is_single_written=True
203-
)
201+
WorkflowFireHistory.objects.filter(workflow=OuterRef("pk"))
204202
.order_by("-date_added")
205203
.values("date_added")[:1]
206204
)

src/sentry/workflow_engine/endpoints/serializers/timeseries_value_serializer.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ def fetch_workflow_hourly_stats(
3535
workflow=workflow,
3636
date_added__gte=start,
3737
date_added__lt=end,
38-
is_single_written=True,
3938
)
4039
.annotate(bucket=TruncHour("date_added"))
4140
.order_by("bucket")

src/sentry/workflow_engine/endpoints/serializers/workflow_group_history_serializer.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ def fetch_workflow_groups_paginated(
114114
workflow=workflow,
115115
date_added__gte=start,
116116
date_added__lt=end,
117-
is_single_written=True,
118117
)
119118

120119
# subquery that retrieves row with the largest date in a group

src/sentry/workflow_engine/endpoints/serializers/workflow_serializer.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ def get_attrs(
3737
last_triggered_map: dict[int, datetime] = dict(
3838
WorkflowFireHistory.objects.filter(
3939
workflow__in=item_list,
40-
is_single_written=True,
4140
)
4241
.values("workflow_id")
4342
.annotate(last_triggered=Max("date_added"))

src/sentry/workflow_engine/processors/workflow_fire_history.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ def create_workflow_fire_histories(
3535
Record that the workflows associated with these actions were fired for this
3636
event.
3737
38-
Only records canonical entries (is_single_written=True). During migration from
39-
dual-write to single-write, entries with is_single_written=False were created
40-
for tracking purposes but are not the canonical record and should not be created
41-
going forward.
42-
4338
If we're reporting a fire due to delayed processing, is_delayed should be True.
4439
"""
4540
# Only write canonical fire history records
@@ -75,7 +70,6 @@ def create_workflow_fire_histories(
7570
workflow_id=workflow_id,
7671
group=event_data.group,
7772
event_id=event_id,
78-
is_single_written=is_single_processing,
7973
)
8074
for workflow_id in workflow_ids
8175
]

tests/sentry/rules/history/backends/test_postgres.py

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -217,28 +217,16 @@ def test_combined_rule_and_workflow_history(self) -> None:
217217
)
218218
)
219219

220-
# Create some WorkflowFireHistory entries with is_single_written=True
220+
# Create some WorkflowFireHistory entries
221221
for i in range(2):
222222
wfh = WorkflowFireHistory.objects.create(
223223
workflow=workflow,
224224
group=self.group,
225225
date_added=before_now(days=i + 3),
226226
event_id=f"workflow_event_{i}",
227-
is_single_written=True,
228227
)
229228
wfh.update(date_added=before_now(days=i + 3))
230229

231-
# Create some WorkflowFireHistory entries with is_single_written=False (should be ignored)
232-
for i in range(2):
233-
wfh = WorkflowFireHistory.objects.create(
234-
workflow=workflow,
235-
group=self.group,
236-
date_added=before_now(days=i + 5),
237-
event_id=f"workflow_event_ignored_{i}",
238-
is_single_written=False,
239-
)
240-
wfh.update(date_added=before_now(days=i + 5))
241-
242230
RuleFireHistory.objects.bulk_create(rule_history)
243231

244232
group_2 = self.create_group()
@@ -254,7 +242,6 @@ def test_combined_rule_and_workflow_history(self) -> None:
254242
group=group_2,
255243
date_added=before_now(days=2),
256244
event_id="workflow_event_group2",
257-
is_single_written=True,
258245
)
259246
new_workflow_history.update(date_added=before_now(days=2))
260247

@@ -382,7 +369,6 @@ def test_combined_rule_and_workflow_history(self) -> None:
382369
workflow=workflow,
383370
group=self.group,
384371
date_added=before_now(hours=1),
385-
is_single_written=True,
386372
)
387373
wfh.update(date_added=before_now(hours=1))
388374
# Hour 3: 2 workflow fire entries
@@ -391,20 +377,9 @@ def test_combined_rule_and_workflow_history(self) -> None:
391377
workflow=workflow,
392378
group=self.group,
393379
date_added=before_now(hours=3),
394-
is_single_written=True,
395380
)
396381
wfh.update(date_added=before_now(hours=3))
397382

398-
# is_single_written=False WFH should be ignored
399-
for _ in range(3):
400-
wfh = WorkflowFireHistory.objects.create(
401-
workflow=workflow,
402-
group=self.group,
403-
date_added=before_now(hours=1),
404-
is_single_written=False,
405-
)
406-
wfh.update(date_added=before_now(hours=1))
407-
408383
RuleFireHistory.objects.bulk_create(rule_history)
409384

410385
results = self.backend.fetch_rule_hourly_stats(rule, before_now(hours=24), before_now())

tests/sentry/workflow_engine/endpoints/serializers/test_workflow_serializer.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,26 +92,15 @@ def test_serialize_full(self) -> None:
9292
workflow=workflow,
9393
group=self.group,
9494
event_id=self.event.event_id,
95-
is_single_written=True,
9695
)
9796
# Too old, shouldn't be used.
9897
WorkflowFireHistory.objects.create(
9998
workflow=workflow,
10099
group=self.group,
101100
event_id=self.event.event_id,
102-
is_single_written=True,
103101
)
104102
history.date_added = workflow.date_added + timedelta(seconds=1)
105103
history.save()
106-
# Dual written, shouldn't be used.
107-
dual_written_history = WorkflowFireHistory.objects.create(
108-
workflow=workflow,
109-
group=self.group,
110-
event_id=self.event.event_id,
111-
is_single_written=False,
112-
)
113-
dual_written_history.date_added = workflow.date_added + timedelta(seconds=2)
114-
dual_written_history.save()
115104

116105
result = serialize(workflow)
117106

tests/sentry/workflow_engine/endpoints/test_organization_workflow_index.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ def setUp(self) -> None:
5353
workflow=workflow,
5454
group=self.group,
5555
event_id=self.event.event_id,
56-
is_single_written=True,
5756
)
5857

5958
def test_simple(self) -> None:
@@ -211,13 +210,6 @@ def test_sort_by_actions(self) -> None:
211210
][0]
212211

213212
def test_sort_by_last_triggered(self) -> None:
214-
# Fresh fire for self.workflow that would impact sorting if not ignored.
215-
WorkflowFireHistory.objects.create(
216-
workflow=self.workflow,
217-
group=self.group,
218-
event_id=self.event.event_id,
219-
is_single_written=False,
220-
)
221213
response = self.get_success_response(
222214
self.organization.slug, qs_params={"sortBy": "lastTriggered"}
223215
)
@@ -358,28 +350,27 @@ def test_sort_by_last_triggered_with_non_single_written_only(self) -> None:
358350
organization_id=self.organization.id, name="Never Fired"
359351
)
360352

361-
workflow_non_single_written_only = self.create_workflow(
362-
organization_id=self.organization.id, name="Non Single Written Only"
353+
workflow_with_history = self.create_workflow(
354+
organization_id=self.organization.id, name="With History"
363355
)
364356
WorkflowFireHistory.objects.create(
365-
workflow=workflow_non_single_written_only,
357+
workflow=workflow_with_history,
366358
group=self.group,
367359
event_id=self.event.event_id,
368-
is_single_written=False,
369360
)
370361

371362
# Test ascending order (lastTriggered)
372363
response = self.get_success_response(
373364
self.organization.slug, qs_params={"sortBy": "lastTriggered"}
374365
)
375366

376-
# Workflows without single-written history should come first, then those with it
367+
# Workflows without history should come first, then those with it
377368
expected_ascending_order = [
378369
self.workflow_three.name,
379370
workflow_never_fired.name,
380-
workflow_non_single_written_only.name,
381371
self.workflow.name,
382372
self.workflow_two.name,
373+
workflow_with_history.name,
383374
]
384375

385376
assert [w["name"] for w in response.data] == expected_ascending_order
@@ -389,11 +380,11 @@ def test_sort_by_last_triggered_with_non_single_written_only(self) -> None:
389380
self.organization.slug, qs_params={"sortBy": "-lastTriggered"}
390381
)
391382

392-
# In descending order, workflows with single-written history should come first
383+
# In descending order, workflows with history should come first
393384
expected_descending_order = [
385+
workflow_with_history.name,
394386
self.workflow_two.name,
395387
self.workflow.name,
396-
workflow_non_single_written_only.name,
397388
workflow_never_fired.name,
398389
self.workflow_three.name,
399390
]

0 commit comments

Comments
 (0)