Only keep the first and most recent yang validator SubmissionCheck for any given submission. Fixes #3542. Commit ready for merge.

- Legacy-Id: 19952
This commit is contained in:
Robert Sparks 2022-02-18 22:46:40 +00:00
parent 7e17801b57
commit ec71083d1d
2 changed files with 32 additions and 1 deletions

View file

@ -0,0 +1,29 @@
# Copyright The IETF Trust 2022 All Rights Reserved
from tqdm import tqdm
from django.core.management.base import BaseCommand
from django.db import migrations
from ietf.submit.models import Submission, SubmissionCheck
class Command(BaseCommand):
help = ("Remove all but the first and last yangchecks for each Submission")
def handle(self, *args, **options):
print("Identifying purgeable SubmissionChecks")
keep = set()
for submission in tqdm(Submission.objects.all()):
qs = submission.checks.filter(checker="yang validation")
if qs.count() == 0:
continue
qs = qs.order_by("time")
keep.add(qs.first().pk)
keep.add(qs.last().pk)
keep.discard(None)
print("Purging SubmissionChecks")
print(
SubmissionCheck.objects.filter(checker="yang validation")
.exclude(pk__in=list(keep))
.delete()
)

View file

@ -55,7 +55,9 @@ class Command(BaseCommand):
if new_res != old_res:
if self.verbosity > 1:
self.stdout.write(" Saving new yang checker results for %s-%s" % (draft.name, draft.rev))
SubmissionCheck.objects.create(submission=submission, checker=checker.name, passed=passed,
qs = submission.checks.filter(checker=checker.name).order_by('time')
submission.checks.filter(checker=checker.name).exclude(pk=qs.first().pk).delete()
submission.checks.create(submission=submission, checker=checker.name, passed=passed,
message=message, errors=errors, warnings=warnings, items=items,
symbol=checker.symbol)
else: