]> git.decadent.org.uk Git - dak.git/commitdiff
dakweb: add sources_in_suite query
authorJoerg Jaspert <joerg@debian.org>
Sun, 30 Nov 2014 13:03:37 +0000 (14:03 +0100)
committerJoerg Jaspert <joerg@debian.org>
Sun, 30 Nov 2014 13:03:37 +0000 (14:03 +0100)
dakweb/queries/source.py [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index a31b7b6..925435b
@@ -41,3 +41,30 @@ def dsc_in_suite(suite=None, source=None):
 
 QueryRegister().register_path('/dsc_in_suite', dsc_in_suite)
 
+
+@bottle.route('/sources_in_suite/<suite>')
+def sources_in_suite(suite=None):
+    """
+    sources_in_suite(suite)
+
+    returns: list of dictionaries
+
+    Returns all source packages and their versions in a given suite.
+    """
+
+    if suite is None:
+        return bottle.HTTPError(503, 'Suite not specified.')
+
+    s = DBConn().session()
+    q = s.query(DBSource).join(Suite, DBSource.suites)
+    q = q.filter(or_(Suite.suite_name == suite, Suite.codename == suite))
+    ret = []
+    for p in q:
+        ret.append({'source':    p.source,
+                    'version':   p.version})
+
+    s.close()
+
+    return json.dumps(ret)
+
+QueryRegister().register_path('/sources_in_suite', sources_in_suite)