[Qa-jenkins-scm] [jenkins.debian.net] 03/04: reproducible: common.py: save the number of UDD queries by doing only a single huge one. Also clean up no more needed functions

Holger Levsen holger at moszumanska.debian.org
Wed Jul 8 11:51:01 UTC 2015


This is an automated email from the git hooks/post-receive script.

holger pushed a commit to branch master
in repository jenkins.debian.net.

commit 3c954457dc85ed3e8d98620a56eb514119aaea10
Author: Mattia Rizzolo <mattia at mapreri.org>
Date:   Wed Jul 8 11:44:12 2015 +0000

    reproducible: common.py: save the number of UDD queries by doing only a single huge one. Also clean up no more needed functions
---
 bin/reproducible_common.py | 61 +++++++++-------------------------------------
 1 file changed, 12 insertions(+), 49 deletions(-)

diff --git a/bin/reproducible_common.py b/bin/reproducible_common.py
index 9cb81b5..2e17b44 100755
--- a/bin/reproducible_common.py
+++ b/bin/reproducible_common.py
@@ -328,37 +328,6 @@ def query_udd(query):
         return []
     return cursor.fetchall()
 
-def is_virtual_package(package):
-    rows = query_udd("""SELECT source FROM sources WHERE source='%s'""" % package)
-    if len(rows) > 0:
-            return False
-    return True
-
-
-def are_virtual_packages(packages):
-    pkgs = "source='" + "' OR source='".join(packages) + "'"
-    query = 'SELECT source FROM sources WHERE %s' % pkgs
-    rows = query_udd(query)
-    result = {x: False for x in packages if (x,) in rows}
-    result.update({x: True for x in packages if (x,) not in rows})
-    return result
-
-
-def bug_has_patch(bug):
-    query = """SELECT id FROM bugs_tags WHERE id=%s AND tag='patch'""" % bug
-    if len(query_udd(query)) > 0:
-        return True
-    return False
-
-
-def bugs_have_patches(bugs):
-    '''
-    This returns a list of tuples where every tuple has a bug with patch
-    '''
-    bugs = 'id=' + ' OR id='.join(bugs)
-    query = """SELECT id FROM bugs_tags WHERE (%s) AND tag='patch'""" % bugs
-    return query_udd(query)
-
 
 def package_has_notes(package):
     # not a really serious check, it'd be better to check the yaml file
@@ -481,9 +450,13 @@ def get_bugs():
     }
     """
     query = """
-        SELECT bugs.id, bugs.source, bugs.done
-        FROM bugs JOIN bugs_tags on bugs.id = bugs_tags.id
-                  JOIN bugs_usertags on bugs_tags.id = bugs_usertags.id
+        SELECT DISTINCT bugs.id, bugs.source, bugs.done, tags.tag
+        FROM bugs JOIN bugs_tags ON bugs.id = bugs_tags.id
+                  JOIN bugs_usertags ON bugs_tags.id = bugs_usertags.id
+                  JOIN sources ON bugs.source=sources.source
+                  LEFT JOIN (
+                    SELECT id, tag FROM bugs_tags WHERE tag='patch'
+                  ) AS tags ON bugs.id = tags.id
         WHERE bugs_usertags.email = 'reproducible-builds at lists.alioth.debian.org'
         AND bugs.id NOT IN (
             SELECT id
@@ -505,26 +478,16 @@ def get_bugs():
     log.info("finding out which usertagged bugs have been closed or at least have patches")
     packages = {}
 
-    bugs_nr = [str(x[0]) for x in rows]
-    bugs_patches = bugs_have_patches(bugs_nr)
-
-    pkgs = [str(x[1]) for x in rows]
-    pkgs_real = are_virtual_packages(pkgs)
-
     for bug in rows:
         if bug[1] not in packages:
             packages[bug[1]] = {}
-        # bug[0] = bug_id, bug[1] = source_name, bug[2] = who_when_done
-        if pkgs_real[str(bug[1])]:
-            continue  # package is virtual, I don't care about virtual pkgs
+        # bug[0] = bug_id, bug[1] = source_name, bug[2] = who_when_done,
+        # bug[3] = tag (patch)
         packages[bug[1]][bug[0]] = {'done': False, 'patch': False}
-        if bug[2]: # if the bug is done
+        if bug[2]:  # if the bug is done
             packages[bug[1]][bug[0]]['done'] = True
-        try:
-            if (bug[0],) in bugs_patches:
-                packages[bug[1]][bug[0]]['patch'] = True
-        except KeyError:
-            log.error('item: ' + str(bug))
+        if bug[3]:  # the bug is patched
+            packages[bug[1]][bug[0]]['patch'] = True
     return packages
 
 def get_trailing_icon(package, bugs):

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/qa/jenkins.debian.net.git



More information about the Qa-jenkins-scm mailing list