def retrieveAlertsJson():
""" Retrieve last 5 Alerts in JSON without IPs """
# set cacheItem independent from url parameters, respect community index
cacheEntry = request.url
# get result from cache
getCacheResult = getCache(cacheEntry, "url")
if getCacheResult is not False:
app.logger.debug('Returning /retrieveAlertsJson from Cache %s' % str(request.remote_addr))
return jsonify(getCacheResult)
# query ES
else:
numAlerts = 35
# Retrieve last X Alerts from ElasticSearch and return JSON formatted with limited alert content
returnResult = formatAlertsJson(queryAlertsWithoutIP(numAlerts, checkCommunityIndex(request)))
setCache(cacheEntry, returnResult, 25, "url")
app.logger.debug('UNCACHED %s' % str(request.url))
return jsonify(returnResult)
评论列表
文章目录