summaryrefslogtreecommitdiff
path: root/devel/management
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2012-11-15 01:00:13 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2012-11-15 01:00:13 -0500
commitaa2836cb3859e05e9524def5ec37706e3299205c (patch)
treeca1de8b399b578aeb5b86490451a136d9986ad1a /devel/management
parent12984bca989485430d3a1be9ea35d3f61239b28f (diff)
parentc3ebf7deae0bb04f1637e9a52e7f9f38d454fec7 (diff)
Merge tag 'release_2012-02-11'
Quick release Conflicts: requirements.txt requirements_prod.txt
Diffstat (limited to 'devel/management')
-rw-r--r--devel/management/commands/rematch_developers.py (renamed from devel/management/commands/rematch_packager.py)47
-rw-r--r--devel/management/commands/reporead.py8
2 files changed, 47 insertions, 8 deletions
diff --git a/devel/management/commands/rematch_packager.py b/devel/management/commands/rematch_developers.py
index 461d83ab..8383cc8d 100644
--- a/devel/management/commands/rematch_packager.py
+++ b/devel/management/commands/rematch_developers.py
@@ -1,20 +1,25 @@
# -*- coding: utf-8 -*-
"""
-rematch_packager command
+rematch_developers command
Match all packages with a packager_str but NULL packager_id to a packager if we
can find one.
-Usage: ./manage.py rematch_packager
+Also, match all flag requests with a NULL user_id that have a user_email
+matching up to a developer if we can find one.
+
+Usage: ./manage.py rematch_developers
"""
from django.core.management.base import NoArgsCommand
+from django.db import transaction
import sys
import logging
from devel.utils import UserFinder
from main.models import Package
+from packages.models import FlagRequest
logging.basicConfig(
level=logging.INFO,
@@ -24,7 +29,7 @@ logging.basicConfig(
logger = logging.getLogger()
class Command(NoArgsCommand):
- help = "Match all packages with a packager_str but NULL packager_id to a packager if we can find one."
+ help = "Match and map objects in database to developer emails"
def handle_noargs(self, **options):
v = int(options.get('verbosity', None))
@@ -35,15 +40,19 @@ class Command(NoArgsCommand):
elif v == 2:
logger.level = logging.DEBUG
- return match_packager()
+ finder = UserFinder()
+ match_packager(finder)
+ match_flagrequest(finder)
-def match_packager():
- finder = UserFinder()
+@transaction.commit_on_success
+def match_packager(finder):
logger.info("getting all unmatched packages")
package_count = matched_count = 0
unknown = set()
for package in Package.objects.filter(packager__isnull=True):
+ if package.packager_str in unknown:
+ continue
logger.debug("package %s, packager string %s",
package.pkgname, package.packager_str)
package_count += 1
@@ -56,9 +65,33 @@ def match_packager():
else:
unknown.add(package.packager_str)
- logger.info("%d packages checked, %d newly matched",
+ logger.info("%d packager strings checked, %d newly matched",
package_count, matched_count)
logger.debug("unknown packagers:\n%s",
"\n".join(unknown))
+
+@transaction.commit_on_success
+def match_flagrequest(finder):
+ logger.info("getting all non-user flag requests")
+ req_count = matched_count = 0
+ unknown = set()
+
+ for request in FlagRequest.objects.filter(user__isnull=True):
+ if request.user_email in unknown:
+ continue
+ logger.debug("email %s", request.user_email)
+ req_count += 1
+ user = finder.find_by_email(request.user_email)
+ if user:
+ request.user = user
+ logger.debug(" found user %s" % user.username)
+ request.save()
+ matched_count += 1
+ else:
+ unknown.add(request.user_email)
+
+ logger.info("%d request emails checked, %d newly matched",
+ req_count, matched_count)
+
# vim: set ts=4 sw=4 et:
diff --git a/devel/management/commands/reporead.py b/devel/management/commands/reporead.py
index 2558d228..30c09c5e 100644
--- a/devel/management/commands/reporead.py
+++ b/devel/management/commands/reporead.py
@@ -193,6 +193,13 @@ def create_multivalued(dbpkg, repopkg, db_attr, repo_attr):
finder = UserFinder()
def populate_pkg(dbpkg, repopkg, force=False, timestamp=None):
+ # we reset the flag date only if the upstream version components change;
+ # e.g. epoch or pkgver, but not pkgrel
+ if dbpkg.epoch is None or dbpkg.epoch != repopkg.epoch:
+ dbpkg.flag_date = None
+ elif dbpkg.pkgver is None or dbpkg.pkgver != repopkg.ver:
+ dbpkg.flag_date = None
+
if repopkg.base:
dbpkg.pkgbase = repopkg.base
else:
@@ -215,7 +222,6 @@ def populate_pkg(dbpkg, repopkg, force=False, timestamp=None):
dbpkg.pgp_signature = repopkg.pgpsig
if timestamp:
- dbpkg.flag_date = None
dbpkg.last_update = timestamp
dbpkg.save()