Skip to content

Commit 713205d

Browse files
committed
Detect and skip some unneeded empty ballot discuss/comment entries
- Legacy-Id: 3903
1 parent 5d9ea97 commit 713205d

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

redesign/importing/import-docs.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -385,14 +385,20 @@ def import_from_idinternal(d, idinternal):
385385

386386
# ballot discusses/comments
387387
if c.ballot in (DocumentComment.BALLOT_DISCUSS, DocumentComment.BALLOT_COMMENT):
388+
skip = False
389+
388390
e = BallotPositionDocEvent()
389391
e.type = "changed_ballot_position"
390392
e.ad = iesg_login_to_person(c.created_by)
391393
last_pos = d.latest_event(BallotPositionDocEvent, type="changed_ballot_position", ad=e.ad)
392394
e.pos = last_pos.pos if last_pos else ballot_position_mapping[None]
393-
c.comment_text = re_comment_discuss_by_tag.sub("", c.comment_text)
395+
c.comment_text = re_comment_discuss_by_tag.sub("", c.comment_text).strip()
394396
if c.ballot == DocumentComment.BALLOT_DISCUSS:
395397
e.discuss = c.comment_text
398+
399+
if not e.discuss and (not last_pos or not last_pos.discuss):
400+
skip = True # skip some bogus empty entries
401+
396402
e.discuss_time = c.datetime()
397403
e.comment = last_pos.comment if last_pos else ""
398404
e.comment_time = last_pos.comment_time if last_pos else None
@@ -406,15 +412,19 @@ def import_from_idinternal(d, idinternal):
406412
# text/time, fudge the time so it's not null
407413
e.discuss_time = c.datetime()
408414
e.comment = c.comment_text
415+
if not e.comment and (not last_pos or not last_pos.comment):
416+
skip = True # skip some bogus empty entries
417+
409418
e.comment_time = c.datetime()
410419
# put header into description
411420
c.comment_text = "[Ballot comment]\n" + c.comment_text
412421

413422
# there are some bogus copies where a secretary has the
414-
# same discuss comment as an AD, skip saving if this is
415-
# one of those
416-
if not (iesg_login_is_secretary(c.created_by)
417-
and DocumentComment.objects.filter(ballot=c.ballot, document=c.document).exclude(created_by=c.created_by)):
423+
# same discuss comment as an AD
424+
if iesg_login_is_secretary(c.created_by) and DocumentComment.objects.filter(ballot=c.ballot, document=c.document).exclude(created_by=c.created_by):
425+
skip = True
426+
427+
if not skip:
418428
save_docevent(d, e, c)
419429

420430
handled = True

0 commit comments

Comments
 (0)