mirror of
https://github.com/jlengrand/bugsink.git
synced 2026-03-10 08:01:17 +00:00
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:
19
events/migrations/0025_fix_never_evict.py
Normal file
19
events/migrations/0025_fix_never_evict.py
Normal 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),
|
||||
]
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user