|
11 | 11 | from django.conf import settings |
12 | 12 | from django.utils import timezone |
13 | 13 |
|
| 14 | +from ietf.doc.models import DocEvent, RelatedDocument |
14 | 15 | from ietf.sync import iana |
15 | 16 | from ietf.sync import rfceditor |
16 | 17 | from ietf.sync.rfceditor import MIN_QUEUE_RESULTS, parse_queue, update_drafts_from_queue |
@@ -180,3 +181,44 @@ def batched(l, n): |
180 | 181 |
|
181 | 182 | for d in updated: |
182 | 183 | 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