From a8674b7e5c726994a102ea8c47d0e82c12e23d51 Mon Sep 17 00:00:00 2001 From: lltommy Date: Fri, 12 Jun 2020 22:39:58 +0200 Subject: Adding endpoint getCountByGPS which could be used to draw a map --- bh20simplewebuploader/main.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'bh20simplewebuploader') diff --git a/bh20simplewebuploader/main.py b/bh20simplewebuploader/main.py index 0cc22df..851d8d5 100644 --- a/bh20simplewebuploader/main.py +++ b/bh20simplewebuploader/main.py @@ -508,6 +508,25 @@ def getDetailsForSeq(): return jsonify([{'uri': x['key']['value'], 'key_label': x['key_label']['value'], 'value': x['value']['value']} for x in result]) +# Endpoint should provide all necessary information to draw a map (!) +@app.route('/api/getCountByGPS', methods=['GET']) +def getCountByGPS(): + query="""SELECT DISTINCT ?location ?location_label ?GPS (count(?fasta) as ?fastaCount) WHERE { + ?fasta ?x[ ?location] . + ?location ?GPS . + OPTIONAL { ?location rdfs:label ?key_tmp_label } + BIND(IF(BOUND(?key_tmp_label),?key_tmp_label, ?location) as ?location_label) + } + GROUP BY ?location ?location_label ?GPS + """ + payload = {'query': query, 'format': 'json'} + r = requests.get(baseURL, params=payload) + result = r.json()['results']['bindings'] + return jsonify([{'Fasta Count': x['fastaCount']['value'], + 'Location': x['location']['value'], + 'LocationLabel': x['location_label']['value'], + 'GPS' :x['GPS']['value']} for x in result]) + @app.route('/api/getSEQCountbytech', methods=['GET']) def getSEQCountbytech(): -- cgit v1.2.3