1
0
Fork 0

explain bind param support, view + aardvark

This commit is contained in:
hkernbach 2015-11-17 13:24:21 +01:00
parent bb814f1c5d
commit 068bee4c80
2 changed files with 112 additions and 95 deletions

View File

@ -170,12 +170,18 @@ controller.post("disableVersionCheck", function(req, res) {
*/ */
controller.post("/query/explain", function(req, res) { controller.post("/query/explain", function(req, res) {
var explain, query = req.body().query; var explain, query = req.body().query,
bindVars = req.body().bindVars;
if (query.length > 0) { if (query.length > 0) {
try { try {
if (bindVars) {
explain = require("org/arangodb/aql/explainer").explain(query, {colors: false}, false, bindVars);
}
else {
explain = require("org/arangodb/aql/explainer").explain(query, {colors: false}, false); explain = require("org/arangodb/aql/explainer").explain(query, {colors: false}, false);
} }
}
catch (e) { catch (e) {
explain = JSON.stringify(e); explain = JSON.stringify(e);
}  } 

View File

@ -102,7 +102,7 @@
inputEditor = ace.edit("aqlEditor"), inputEditor = ace.edit("aqlEditor"),
varsEditor = ace.edit("varsEditor"); varsEditor = ace.edit("varsEditor");
inputEditor.setValue(this.getCustomQueryValueByName(queryName)); inputEditor.setValue(this.getCustomQueryValueByName(queryName));
varsEditor.setValue(this.getCustomQueryParameterByName(queryName)); varsEditor.setValue(JSON.stringify(this.getCustomQueryParameterByName(queryName)));
this.deselect(varsEditor); this.deselect(varsEditor);
this.deselect(inputEditor); this.deselect(inputEditor);
$('#querySelect').val(queryName); $('#querySelect').val(queryName);
@ -541,6 +541,14 @@
bindVars = '{}'; bindVars = '{}';
} }
if (typeof bindVars === 'string') {
try {
bindVars = JSON.parse(bindVars);
}
catch (err) {
console.log("could not parse bind parameter");
}
}
this.collection.add({ this.collection.add({
name: saveName, name: saveName,
parameter: bindVars, parameter: bindVars,
@ -672,6 +680,7 @@
}; };
var bindVars = varsEditor.getValue(); var bindVars = varsEditor.getValue();
if (bindVars.length > 0) { if (bindVars.length > 0) {
try { try {
var params = JSON.parse(bindVars); var params = JSON.parse(bindVars);
@ -681,6 +690,7 @@
} }
catch (e) { catch (e) {
arangoHelper.arangoError("Query error", "Could not parse bind parameters."); arangoHelper.arangoError("Query error", "Could not parse bind parameters.");
return false;
} }
} }
return JSON.stringify(data); return JSON.stringify(data);
@ -859,15 +869,19 @@
var self = this; var self = this;
var outputEditor = ace.edit("queryOutput"); var outputEditor = ace.edit("queryOutput");
var queryData = this.readQueryData();
$('.queryExecutionTime').text(''); $('.queryExecutionTime').text('');
this.execPending = false;
if (queryData) {
window.progressView.show( window.progressView.show(
"Explain is operating..." "Explain is operating..."
); );
this.execPending = false;
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "/_admin/aardvark/query/explain/", url: "/_admin/aardvark/query/explain/",
data: this.readQueryData(), data: queryData,
contentType: "application/json", contentType: "application/json",
processData: false, processData: false,
success: function (data) { success: function (data) {
@ -881,6 +895,7 @@
} }
}, },
error: function (data) { error: function (data) {
window.progressView.hide();
try { try {
var temp = JSON.parse(data.responseText); var temp = JSON.parse(data.responseText);
arangoHelper.arangoError("Explain error", temp.errorNum); arangoHelper.arangoError("Explain error", temp.errorNum);
@ -894,7 +909,7 @@
} }
} }
}); });
}
/* /*
var self = this; var self = this;
$("svg#explainOutput").html(); $("svg#explainOutput").html();
@ -952,6 +967,9 @@
// clear result // clear result
outputEditor.setValue(''); outputEditor.setValue('');
var queryData = this.readQueryData();
if (queryData) {
window.progressView.show( window.progressView.show(
"Query is operating..." "Query is operating..."
); );
@ -963,7 +981,7 @@
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "/_api/cursor", url: "/_api/cursor",
data: this.readQueryData(), data: queryData,
contentType: "application/json", contentType: "application/json",
processData: false, processData: false,
success: function (data) { success: function (data) {
@ -1008,11 +1026,11 @@
} }
} }
}); });
}
}, },
submitQuery: function () { submitQuery: function () {
var outputEditor = ace.edit("queryOutput"); var outputEditor = ace.edit("queryOutput");
// this.fillExplain();
this.fillResult(this.switchTab.bind(this, "result-switch")); this.fillResult(this.switchTab.bind(this, "result-switch"));
outputEditor.resize(); outputEditor.resize();
var inputEditor = ace.edit("aqlEditor"); var inputEditor = ace.edit("aqlEditor");
@ -1021,14 +1039,7 @@
}, },
explainQuery: function() { explainQuery: function() {
this.fillExplain(); this.fillExplain();
/*
this.fillExplain(this.switchTab.bind(this, "explain-switch"));
this.execPending = true;
var inputEditor = ace.edit("aqlEditor");
this.deselect(inputEditor);
*/
}, },
// This function changes the focus onto the tab that has been clicked // This function changes the focus onto the tab that has been clicked