Commit 9f56a878 authored by Patrick Godwin's avatar Patrick Godwin
Browse files

serve.py: add snapshot route, scald.js: use Series for 2d snapshots

parent 163d968b
Pipeline #56231 passed with stages
in 1 minute and 35 seconds
......@@ -103,6 +103,17 @@ def serve_timeseries(measurement, start, end, config):
return bottle.HTTPResponse(status=200, headers=JSON_HEADER, body=json.dumps(response).replace("NaN","null"))
def serve_snapshot(measurement, start, end, config):
consumer = config_to_consumer(config['database'])
time, snapshot, dims = consumer.retrieve_snapshot(measurement)
### format request
response = [{'x':snapshot[dims['x']], 'y':snapshot[dims['y']]}]
### return data
return bottle.HTTPResponse(status=200, headers=JSON_HEADER, body=json.dumps(response))
def serve_heatmap(measurement, start, end, config):
column, _, tag_key, tag_filters, aggregate, dt, far, datetime = parse_query(bottle.request.query)
......@@ -335,6 +346,7 @@ def main(args=None):
app = bottle.Bottle()
app.route("/", "GET", functools.partial(index, config=config, use_cgi=use_cgi, script_name=script_name))
app.route("/api/timeseries/<measurement>/<start:int>/<end:int>", "GET", functools.partial(serve_timeseries, config=config))
app.route("/api/snapshot/<measurement>/<start:int>/<end:int>", "GET", functools.partial(serve_snapshot, config=config))
app.route("/api/heatmap/<measurement>/<start:int>/<end:int>", "GET", functools.partial(serve_heatmap, config=config))
app.route("/api/latest/<measurement>/<start:int>/<end:int>", "GET", functools.partial(serve_latest, config=config))
app.route("/api/ifar/<measurement>/<start:int>/<end:int>", "GET", functools.partial(serve_ifar, config=config))
......
......@@ -418,7 +418,7 @@ class Bar extends _TimePlot {
class Series extends _TimePlot {
constructor(divname, title, measurement, schema, script_name, segment, refresh_interval = -1, data_options = {}, grid = {}, layout = {}, options = {}, delay = 0) {
super(divname, title, measurement, schema, script_name, segment, refresh_interval, data_options, grid, layout, options, delay);
this.base_url = new URL(`${script_name}api/latest/${this.measurement}/`, window.location.href);
this.base_url = new URL(`${script_name}api/snapshot/${this.measurement}/`, window.location.href);
}
_update_plot_data(respdata) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment