[Qa-jenkins-scm] [jenkins.debian.net] 01/01: reproducible debian: scheduler: run random() in a subquery and distinct in a parent query for postgres compatibility

Holger Levsen holger at layer-acht.org
Mon Dec 19 13:42:19 UTC 2016


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 3d5599971e80226ad75d9e6c42e8e8446e51c8e8
Author: Mattia Rizzolo <mattia at debian.org>
Date:   Mon Dec 19 14:16:51 2016 +0100

    reproducible debian: scheduler: run random() in a subquery and distinct in a parent query for postgres compatibility
    
    https://stackoverflow.com/questions/11401229/how-to-use-select-distinct-with-random-function-in-postgresql
    Signed-off-by: Holger Levsen <holger at layer-acht.org>
---
 bin/reproducible_scheduler.py | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/bin/reproducible_scheduler.py b/bin/reproducible_scheduler.py
index 649eba2..b1721f6 100755
--- a/bin/reproducible_scheduler.py
+++ b/bin/reproducible_scheduler.py
@@ -14,7 +14,6 @@ import sys
 import lzma
 import deb822
 import aptsources.sourceslist
-import random
 import smtplib
 from subprocess import call
 from apt_pkg import version_compare
@@ -391,14 +390,17 @@ def add_up_numbers(packages, arch):
 
 def query_untested_packages(suite, arch, limit):
     criteria = 'not tested before, randomly sorted'
-    query = """SELECT DISTINCT sources.id, sources.name FROM sources
-               WHERE sources.suite='{suite}' AND sources.architecture='{arch}'
-               AND sources.id NOT IN
+    query = """SELECT DISTINCT *
+               FROM (
+                    SELECT sources.id, sources.name FROM sources
+                    WHERE sources.suite='{suite}' AND sources.architecture='{arch}'
+                    AND sources.id NOT IN
                        (SELECT schedule.package_id FROM schedule)
-               AND sources.id NOT IN
+                    AND sources.id NOT IN
                        (SELECT results.package_id FROM results)
-               ORDER BY random()
-               LIMIT {limit}""".format(suite=suite, arch=arch, limit=limit)
+                    ORDER BY random()
+                ) AS tmp
+                LIMIT {limit}""".format(suite=suite, arch=arch, limit=limit)
     packages = query_db(query)
     print_schedule_result(suite, arch, criteria, packages)
     return packages

-- 
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