From adedbaadd3fb7468c894ba94595950c41bb61050 Mon Sep 17 00:00:00 2001 From: Joerg Jaspert Date: Sun, 30 Nov 2014 14:03:37 +0100 Subject: [PATCH] dakweb: add sources_in_suite query --- dakweb/queries/source.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) mode change 100644 => 100755 dakweb/queries/source.py diff --git a/dakweb/queries/source.py b/dakweb/queries/source.py old mode 100644 new mode 100755 index a31b7b6d..925435b1 --- a/dakweb/queries/source.py +++ b/dakweb/queries/source.py @@ -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/') +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) -- 2.39.5