def retrieveDatasetAlertTypesPerMonth():
""" Retrieve the attacks / day in the last x days from elasticsearch,
split by attack group
and return as JSON for the last x months, defaults to last month,
if no GET parameter days is given
"""
# get result from cache
getCacheResult = getCache(request.url, "url")
if getCacheResult is not False:
return jsonify(getCacheResult)
# query ES
else:
if not request.args.get('days'):
# Using default : within the last month
returnResult = formatDatasetAlertTypesPerMonth(queryDatasetAlertTypesPerMonth(None, checkCommunityIndex(request)))
else:
returnResult = formatDatasetAlertTypesPerMonth(queryDatasetAlertTypesPerMonth(request.args.get('days'), checkCommunityIndex(request)))
setCache(request.url, returnResult, 3600, "url")
return jsonify(returnResult)
评论列表
文章目录