Commit 1c706b1c authored by Heinz N. Gies's avatar Heinz N. Gies

Make result for querries more human readable

parent 8171447f
......@@ -65,19 +65,21 @@ if (QueryString.metric && QueryString.bucket) {
function q() {
var query = $("#query").val();
msgpack.download("?q=" + query, {header: {accept:"application/x-msgpack"}}, function(res) {
console.log("Fetched " + res.d[0].v.length + " elements in " + res.t / 1000 + "ms");
console.log(res);
console.log("Fetched " + res.results[0].values.length * res.results[0] + " elements in " +
res.query_time / 1000 + "ms");
$("#permalink").attr("href", "/?query=" + encodeURIComponent(query));
$("#permalink").show();
$("#time").text((res.t / 1000) + "ms");
$("#time").text((res.query_time / 1000) + "ms");
$("#timewrap").show();
var start = res.s * 1000,
var start = res.start * 1000,
legend = [],
data;
data = res.d.map(function(s) {
var resolution = s.r,
values = s.v,
data = res.results.map(function(s) {
var resolution = s.resolution,
values = s.values,
points = new Array(values.length);
legend.push(s.n);
......
......@@ -29,23 +29,23 @@ handle(Req, State) ->
cowboy_req:reply(400, [], Error, Req1),
{ok, Req2, State};
{T, {ok, Start, R2}} ->
R3 = [#{n => Name,
r => Resolution,
v => mmath_bin:to_list(Data),
t => <<"metrics">>}
R3 = [#{name => Name,
resolution => Resolution,
values => mmath_bin:to_list(Data),
type => <<"metrics">>}
|| #{name := Name,
data := Data,
type := metrics,
resolution := Resolution} <- R2],
R4 = [#{n => Name,
v => Data,
t => <<"events">>}
R4 = [#{name => Name,
values => Data,
type => <<"events">>}
|| #{name := Name,
data := Data,
type := events} <- R2],
D = #{s => Start,
t => T,
d => R3 ++ R4},
D = #{start => Start,
query_time => T,
results => R3 ++ R4},
{ContentType, Req2} = content_type(Req1),
send(ContentType, D, Req2, State)
end
......
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