def get_heatmap(keyword): hour = int(flask.request.args.get('hour')) past_day = datetime.datetime.now() - datetime.timedelta(hours=24 - hour * 4) end = past_day + datetime.timedelta(hours=4) # grab all the articles in the past 24 hours that have entities match = {'$match': { 'timestamp': {'$gt': past_day, '$lt': end}, 'keywords': keyword}} return json.dumps(database.get_latest_entities(match))
def get_heatmap(keyword): hour = int(flask.request.args.get('hour')) past_day = datetime.datetime.now() - datetime.timedelta(hours=24 - hour * 4) end = past_day + datetime.timedelta(hours=4) # grab all the articles in the past 24 hours that have entities match = { '$match': { 'timestamp': { '$gt': past_day, '$lt': end }, 'keywords': keyword } } return json.dumps(database.get_latest_entities(match))
def get_entities(): return json.dumps(database.get_latest_entities())