Fix never_evict for the "conditional ummute" case

The key phrase from our codebase was:

> # .save() will be called by the caller of this function

But this wasn't the case for the conditionally called path.

Adds data-fixing migration too.

Fix #292
This commit is contained in:
Klaas van Schelven
2026-01-06 11:07:53 +01:00
parent 4fe8bd3fad
commit b7f6331cc6
2 changed files with 21 additions and 2 deletions

View File

@@ -0,0 +1,19 @@
from django.db import migrations
def fix_never_evict(apps, schema_editor):
Event = apps.get_model("events", "Event")
cnt = Event.objects.filter(never_evict=False, turningpoint__isnull=False).update(never_evict=True)
if cnt:
print(f"\nUpdated {cnt} Event records to set never_evict=True where turningpoint is not null.")
class Migration(migrations.Migration):
dependencies = [
("events", "0024_remove_event_debug_info"),
]
operations = [
migrations.RunPython(fix_never_evict, migrations.RunPython.noop),
]

View File

@@ -459,6 +459,8 @@ class BaseIngestAPIView(View):
issue, triggering_event=event,
unmute_metadata={"mute_for": {"unmute_after": issue.unmute_after}})
cls.count_issue_periods_and_act_on_it(issue, event, digested_at)
if event.never_evict:
# as a sort of poor man's django-dirtyfields (which we haven't adopted for simplicity's sake) we simply do
# this manually for a single field; we know that if never_evict has been set, it's always been set after the
@@ -470,8 +472,6 @@ class BaseIngestAPIView(View):
if release.version + "\n" not in issue.events_at:
issue.events_at += release.version + "\n"
cls.count_issue_periods_and_act_on_it(issue, event, digested_at)
issue.save()
# intentionally at the end: possible future optimization is to push this out of the transaction (or even use