Merged in [19952] from rjsparks@nostrum.com:
Only keep the first and most recent yang validator SubmissionCheck for any given submission. Fixes #3542.
- Legacy-Id: 19960
Note: SVN reference [19952] has been migrated to Git commit ec71083d1d
This commit is contained in:
commit
9aba75e5a3
29
ietf/submit/management/commands/purge_yang_checks.py
Normal file
29
ietf/submit/management/commands/purge_yang_checks.py
Normal 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()
|
||||
)
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue