def daily_hours(): '''Return a JSON of weekly event data by hour''' if request.method == 'POST': data = json.loads(request.form['data']) df = tr.to_df(data) json_return = tr.daily_hours(df=df, to_json=True) resp = Response(json.dumps(json_return), status=200, mimetype='application/json') return resp
def daily(): '''Return a JSON of daily summed event data''' if request.method == 'POST': data = json.loads(request.form['data']) how = json.loads(request.form['how']) df = tr.to_df(data) json_return = tr.daily(df=df, how=how) resp = Response(json.dumps(json_return), status=200, mimetype='application/json') return resp
def resample(): '''Return a JSON of resampled event data''' if request.method == 'POST': data = json.loads(request.form['data']) freq = json.loads(request.form['freq']) df = tr.to_df(data) json_return = tr.resample(df=df, freq=freq) resp = Response(json.dumps(json_return), status=200, mimetype='application/json') return resp
def forward(): '''Return a JSON of a given number of hourly events''' if request.method == 'POST': data = json.loads(request.form['data']) periods = json.loads(request.form['periods']) df = tr.to_df(data) json_return = tr.forward(df=df, periods=periods) resp = Response(json.dumps(json_return), status=200, mimetype='application/json') return resp
def rolling_sum(): '''Return a JSON of rolling summed event data''' if request.method == 'POST': data = json.loads(request.form['data']) freq = json.loads(request.form['freq']) window = int(request.form['window']) df = tr.to_df(data) json_return = tr.rolling_sum(df=df, window=window, freq=freq) resp = Response(json.dumps(json_return), status=200, mimetype='application/json') return resp