def retrieveAlertsCount():
""" Retrieve number of alerts in timeframe (GET-Parameter time as decimal or "day") """
# Retrieve Number of Alerts from ElasticSearch and return as xml / json
if not request.args.get('time'):
app.logger.error('No time GET-parameter supplied in retrieveAlertsCount. Must be decimal number (in minutes) or string "day"')
return app.config['DEFAULTRESPONSE']
else:
if request.args.get('out') and request.args.get('out') == 'json':
# get result from cache
getCacheResult = getCache(request.url, "url")
if getCacheResult is not False:
return jsonify(getCacheResult)
else:
returnResult = formatAlertsCount(queryAlertsCount(request.args.get('time'), checkCommunityIndex(request)), 'json')
setCache(request.url, returnResult, 60, "url")
return jsonify(returnResult)
else:
# get result from cache
getCacheResult = getCache(request.url, "url")
if getCacheResult is not False:
return Response(getCacheResult, mimetype='text/xml')
else:
returnResult = formatAlertsCount(queryAlertsCount(request.args.get('time'), checkCommunityIndex(request)), 'xml')
setCache(request.url, returnResult, 60, "url")
return Response(returnResult, mimetype='text/xml')
评论列表
文章目录