Skip to content

Commit 5ede134

Browse files
authored
fix: task that repairs bad docevents related to subseries removals (#9053)
1 parent ec3aec1 commit 5ede134

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

ietf/sync/tasks.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from django.conf import settings
1212
from django.utils import timezone
1313

14+
from ietf.doc.models import DocEvent, RelatedDocument
1415
from ietf.sync import iana
1516
from ietf.sync import rfceditor
1617
from ietf.sync.rfceditor import MIN_QUEUE_RESULTS, parse_queue, update_drafts_from_queue
@@ -180,3 +181,44 @@ def batched(l, n):
180181

181182
for d in updated:
182183
log.log("Added history entry for %s" % d.display_name())
184+
185+
@shared_task
186+
def fix_subseries_docevents_task():
187+
"""Repairs DocEvents related to bugs around removing docs from subseries
188+
189+
Removes bogus and repairs the date of non-bogus DocEvents
190+
about removing RFCs from subseries
191+
192+
This is designed to be a one-shot task that should be removed
193+
after running it. It is intended to be safe if it runs more than once.
194+
"""
195+
log.log("Repairing DocEvents related to bugs around removing docs from subseries")
196+
bogus_event_descs = [
197+
"Removed rfc8499 from bcp218",
198+
"Removed rfc7042 from bcp184",
199+
"Removed rfc9499 from bcp238",
200+
"Removed rfc5033 from std74",
201+
"Removed rfc3228 from bcp55",
202+
"Removed rfc8109 from std85",
203+
]
204+
DocEvent.objects.filter(
205+
type="sync_from_rfc_editor", desc__in=bogus_event_descs
206+
).delete()
207+
needs_moment_fix = [
208+
"Removed rfc8499 from bcp219",
209+
"Removed rfc7042 from bcp141",
210+
"Removed rfc5033 from bcp133",
211+
"Removed rfc3228 from bcp57",
212+
]
213+
# Assumptions (which have been manually verified):
214+
# 1) each of the above RFCs is obsoleted by exactly one other RFC
215+
# 2) each of the obsoleting RFCs has exactly one published_rfc docevent
216+
for desc in needs_moment_fix:
217+
obsoleted_rfc_name = desc.split(" ")[1]
218+
obsoleting_rfc = RelatedDocument.objects.get(
219+
relationship_id="obs", target__name=obsoleted_rfc_name
220+
).source
221+
obsoleting_time = obsoleting_rfc.docevent_set.get(type="published_rfc").time
222+
DocEvent.objects.filter(type="sync_from_rfc_editor", desc=desc).update(
223+
time=obsoleting_time
224+
)

0 commit comments

Comments
 (0)