summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjelle van der Waa <jelle@vdwaa.nl>2019-04-28 13:34:03 +0200
committerGitHub <noreply@github.com>2019-04-28 13:34:03 +0200
commit55f59f4ffaa331cd0cf9674f0ee18daf123a75ad (patch)
tree01c6c020e9b921a818cdfa7e6e3e9f0a21368560
parentd8562ac124c5ce128a64b7dcd3f5cf6984204bde (diff)
parent08c044f74f75ac4fc9a71dc34eac22688b938c18 (diff)
downloadarchweb-55f59f4ffaa331cd0cf9674f0ee18daf123a75ad.tar.gz
archweb-55f59f4ffaa331cd0cf9674f0ee18daf123a75ad.zip
Merge pull request #216 from jelly/cleanup_signoffs
populate_signoffs: clean up old signoff(specifications)
-rw-r--r--packages/management/commands/populate_signoffs.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/packages/management/commands/populate_signoffs.py b/packages/management/commands/populate_signoffs.py
index 217eff97..4e4de2d5 100644
--- a/packages/management/commands/populate_signoffs.py
+++ b/packages/management/commands/populate_signoffs.py
@@ -17,7 +17,7 @@ from xml.etree.ElementTree import XML
from django.conf import settings
from django.core.management.base import BaseCommand
-from ...models import SignoffSpecification
+from ...models import FakeSignoffSpecification, SignoffSpecification, Signoff
from ...utils import get_signoff_groups
from devel.utils import UserFinder
@@ -41,7 +41,8 @@ is signoff-eligible and does not have an existing comment attached"""
elif v >= 2:
logger.level = logging.DEBUG
- return add_signoff_comments()
+ add_signoff_comments()
+ cleanup_signoff_comments()
def svn_log(pkgbase, repo):
'''Retrieve the most recent SVN log entry for the given pkgbase and
@@ -103,4 +104,18 @@ def add_signoff_comments():
except:
logger.exception("error getting SVN log for %s", group.pkgbase)
+def cleanup_signoff_comments():
+ logger.info("getting all signoff groups")
+ groups = get_signoff_groups()
+
+ id_signoffs = [signoff.id for g in groups for signoff in g.signoffs]
+ logger.info("Keeping %s signoffs", len(id_signoffs))
+ # FakeSignoffSpecification's have no id
+ id_signoffspecs = [g.specification.id for g in groups if not isinstance(g.specification, FakeSignoffSpecification)]
+ logger.info("Keeping %s signoffspecifications", len(id_signoffspecs))
+
+ Signoff.objects.exclude(id__in=id_signoffs).delete()
+ SignoffSpecification.objects.exclude(id__in=id_signoffspecs).delete()
+
+
# vim: set ts=4 sw=4 et: