Skip to content

Commit 299c3d7

Browse files
armenzgjjbayer
authored andcommitted
chore(grouphistory): Stop using prev_history (#102474)
While investigating #102470, I realized we don't actually use it for anything useful. In order to delete the column, we first need to stop making use of it (see [docs](https://develop.sentry.dev/backend/application-domains/database-migrations/#deleting-columns) for instructions).
1 parent f24820a commit 299c3d7

File tree

6 files changed

+11
-17
lines changed

6 files changed

+11
-17
lines changed

src/sentry/deletions/defaults/grouphistory.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from sentry.models.grouphistory import GroupHistory
33

44

5+
# XXX: Once we remove prev_history from GroupHistory, we can simplify this to a regular BulkModelDeletionTask.
56
class GroupHistoryDeletionTask(ModelDeletionTask[GroupHistory]):
67
"""
78
Specialized deletion handling that operates per group

src/sentry/models/grouphistory.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,6 @@ def record_group_history(
313313
user_id=user_id,
314314
team_id=team_id,
315315
status=status,
316-
prev_history=prev_history,
317316
prev_history_date=prev_history.date_added if prev_history else None,
318317
)
319318

@@ -352,7 +351,6 @@ def get_prev_history_date(group: Group, status: int) -> datetime.datetime | None
352351
team_id=team_id,
353352
user_id=user_id,
354353
status=status,
355-
prev_history=get_prev_history(group, status),
356354
prev_history_date=get_prev_history_date(group, status),
357355
)
358356
for group in groups

src/sentry/testutils/factories.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1963,13 +1963,9 @@ def create_group_history(
19631963
release: Release | None = None,
19641964
user_id: int | None = None,
19651965
team_id: int | None = None,
1966-
prev_history: GroupHistory | None = None,
1966+
prev_history_date: datetime | None = None,
19671967
date_added: datetime | None = None,
19681968
) -> GroupHistory:
1969-
prev_history_date = None
1970-
if prev_history:
1971-
prev_history_date = prev_history.date_added
1972-
19731969
kwargs = {}
19741970
if date_added:
19751971
kwargs["date_added"] = date_added
@@ -1981,7 +1977,6 @@ def create_group_history(
19811977
user_id=user_id,
19821978
team_id=team_id,
19831979
status=status,
1984-
prev_history=prev_history,
19851980
prev_history_date=prev_history_date,
19861981
**kwargs,
19871982
)

tests/sentry/core/endpoints/test_team_time_to_resolution.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def test_simple(self) -> None:
3232
group1,
3333
GroupHistoryStatus.RESOLVED,
3434
user_id=self.user.id,
35-
prev_history=gh1,
35+
prev_history_date=gh1.date_added,
3636
date_added=before_now(days=2),
3737
)
3838

@@ -47,7 +47,7 @@ def test_simple(self) -> None:
4747
group2,
4848
GroupHistoryStatus.RESOLVED,
4949
user_id=self.user.id,
50-
prev_history=gh2,
50+
prev_history_date=gh2.date_added,
5151
)
5252
today = str(now().date())
5353
yesterday = str((now() - timedelta(days=1)).date())
@@ -72,15 +72,15 @@ def test_simple(self) -> None:
7272
group2,
7373
GroupHistoryStatus.RESOLVED,
7474
user_id=self.user.id,
75-
prev_history=gh2,
75+
prev_history_date=gh2.date_added,
7676
)
7777

7878
# making sure it doesnt bork anything
7979
self.create_group_history(
8080
group2,
8181
GroupHistoryStatus.DELETED,
8282
user_id=self.user.id,
83-
prev_history=gh2,
83+
prev_history_date=gh2.date_added,
8484
)
8585
# Make sure that if we have a `GroupHistory` row with no prev history then we don't crash.
8686
self.create_group_history(
@@ -114,7 +114,7 @@ def test_filter_by_environment(self) -> None:
114114
group1,
115115
GroupHistoryStatus.RESOLVED,
116116
user_id=self.user.id,
117-
prev_history=gh1,
117+
prev_history_date=gh1.date_added,
118118
date_added=before_now(days=2),
119119
)
120120

tests/sentry/deletions/test_group.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,15 @@ def test_grouphistory_relation(self) -> None:
135135
history_two = self.create_group_history(
136136
group=group,
137137
status=GroupHistoryStatus.RESOLVED,
138-
prev_history=history_one,
138+
prev_history_date=history_one.date_added,
139139
)
140140
other_history_one = self.create_group_history(
141141
group=other_group, status=GroupHistoryStatus.ONGOING
142142
)
143143
other_history_two = self.create_group_history(
144144
group=other_group,
145145
status=GroupHistoryStatus.RESOLVED,
146-
prev_history=other_history_one,
146+
prev_history_date=other_history_one.date_added,
147147
)
148148
with self.tasks():
149149
delete_groups_for_project(

tests/sentry/models/test_grouphistory.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ def test_multi_history(self) -> None:
7878
prev_history = self.create_group_history(self.group, GroupHistoryStatus.UNRESOLVED)
7979
assert get_prev_history(self.group, GroupHistoryStatus.RESOLVED) == prev_history
8080
prev_history = self.create_group_history(
81-
self.group, GroupHistoryStatus.RESOLVED, prev_history=prev_history
81+
self.group, GroupHistoryStatus.RESOLVED, prev_history_date=prev_history.date_added
8282
)
8383
assert get_prev_history(self.group, GroupHistoryStatus.UNRESOLVED) == prev_history
8484
prev_history = self.create_group_history(
85-
self.group, GroupHistoryStatus.UNRESOLVED, prev_history=prev_history
85+
self.group, GroupHistoryStatus.UNRESOLVED, prev_history_date=prev_history.date_added
8686
)
8787
assert get_prev_history(self.group, GroupHistoryStatus.RESOLVED) == prev_history

0 commit comments

Comments
 (0)