From: Joerg Jaspert Date: Sun, 30 Nov 2014 13:03:37 +0000 (+0100) Subject: dakweb: add sources_in_suite query X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=adedbaadd3fb7468c894ba94595950c41bb61050;p=dak.git dakweb: add sources_in_suite query --- 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)