use splunk's PostProcessManager to request tile data instead of

hardcoded job requests
This commit is contained in:
Dani Carrion 2015-08-31 18:22:52 +02:00
parent b69a8e5354
commit d56b403cfe

View File

@ -58,6 +58,12 @@
splunk.prototype = { splunk.prototype = {
setManager: function (PostProcessManager, managerId) {
this.searchManagerId = managerId;
this.managerClass = PostProcessManager;
this.managers = [];
},
/** /**
* return the torque tile encoded in an efficient javascript * return the torque tile encoded in an efficient javascript
* structure: * structure:
@ -330,40 +336,19 @@
tileBounds.maxLng <= 180 tileBounds.maxLng <= 180
) { ) {
var options = { if (!self.managers[coord.zoom + "_" + coord.x + "_" + coord.y]) {
host: 'localhost', self.managers[coord.zoom + "_" + coord.x + "_" + coord.y] = new self.managerClass({
port: '8000', id: coord.zoom + "_" + coord.x + "_" + coord.y,
sid: '1439866488.13', managerid: self.searchManagerId,
bounds: tileBounds search: "geofilter south=" + tileBounds.minLat + " west=" + tileBounds.minLng + " north=" + tileBounds.maxLat + " east=" + tileBounds.maxLng + " maxclusters=65536"
});
self.managers[coord.zoom + "_" + coord.x + "_" + coord.y].data("results", {count: 0, output_mode: 'json_rows'}).on("data", function (results) {
console.log("Got " + (results.data().rows.length - 8) + " bins for this tile");
callback(results.data());
});
} }
var template = 'http://{{host}}:{{port}}/en-US/splunkd/__raw/services/search/jobs/{{sid}}/results_preview?output_mode=json_rows&count=65536&show_metadata=false&search=geofilter+south={{bounds.minLat}}+west={{bounds.minLng}}+north={{bounds.maxLat}}+east={{bounds.maxLng}}+maxclusters%3D65536'; self.managers[coord.zoom + "_" + coord.x + "_" + coord.y].startSearch();
var queryString = Mustache.render(template,options);
console.log(queryString);
$.getJSON(queryString,function(data) {
console.log("Got " + (data.rows.length-8) + " bins for this tile");
callback(data);
});
// $.ajax({
// type: "POST",
// crossDomain: true,
// url: "https://localhost:8089/servicesNS/admin/search/search/jobs/export",
// username: 'admin',
// password: 'cartodb',
// dataType: 'text',
// data: queryString,
// success: callback,
// beforeSend: function(xhr) {
// xhr.setRequestHeader(
// 'Authorization',
// 'Basic ' + window.btoa(unescape(encodeURIComponent('admin' + ':' + 'cartodb')))
// )
// }
// });
} }
} }
@ -691,11 +676,6 @@
for(var k in opt) { for(var k in opt) {
self.options[k] = opt[k]; self.options[k] = opt[k];
} }
//in Windshaft, this was happening after an ajax call. Calling self._setReady() too early causes the viz to fail, so it is delayed here. We should fix this
setTimeout(function(){
self._setReady(true);
},500)
} }
}; };