From 789b5445cf9b3f2e67911dfd6aee4e836708aa05 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sun, 23 Nov 2008 01:54:35 -0600 Subject: reporead: force load of package list from database Rather than load one package at a time and put unnecessary load on the database, load them all at once upfront since we are going to need 99% of them anyway. This shifts the burden of work from the database to the python script itself. Signed-off-by: Dan McGee --- scripts/reporead.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/reporead.py b/scripts/reporead.py index 54fc3fa..9904201 100755 --- a/scripts/reporead.py +++ b/scripts/reporead.py @@ -45,7 +45,7 @@ sys.path[0] = archweb_app_path import settings setup_environ(settings) from cStringIO import StringIO -from logging import WARNING,INFO +from logging import WARNING,INFO,DEBUG from main.models import Arch, Package, Repo class SomethingFishyException(Exception): @@ -161,6 +161,10 @@ def db_update(archname, pkgs): repository = Repo.objects.get(name__iexact=pkgs[0].repo) architecture = Arch.objects.get(name__iexact=archname) dbpkgs = Package.objects.filter(arch=architecture, repo=repository) + # It makes sense to fully evaluate our DB query now because we will + # be using 99% of the objects in our "in both sets" loop. Force eval + # by calling len() on the QuerySet. + dblist = list(dbpkgs) now = datetime.now() # go go set theory! @@ -291,7 +295,7 @@ def parse_repo(repopath): if not os.path.exists(repopath): logger.error("Could not read file %s", repopath) - logger.info("Reading repo tarfile") + logger.info("Reading repo tarfile %s", repopath) filename = os.path.split(repopath)[1] rindex = filename.rindex('.db.tar.gz') reponame = filename[:rindex] -- cgit v1.2.3-24-g4f1b