Skip to content

Commit

Permalink
Merge branch 'master' of github.com:sirensolutions/kibi-internal
Browse files Browse the repository at this point in the history
  • Loading branch information
szydan committed May 18, 2016
2 parents ea038dd + f6843a3 commit 2d2ec6c
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/plugins/kibi_core/lib/query_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ QueryEngine.prototype.loadPredefinedData = function () {
if (self.config.get('pkg.kibiEnterpriseEnabled')) {
return self._loadDatasources().then(function () {
return self._loadQueries().then(function () {
fulfill(true);
return self._refreshKibiIndex().then(function () {
fulfill(true);
});
});
});
} else {
Expand Down Expand Up @@ -143,6 +145,14 @@ QueryEngine.prototype._loadTemplatesMapping = function () {
});
};

QueryEngine.prototype._refreshKibiIndex = function () {
var self = this;
return self.client.indices.refresh({
index: self.config.get('kibana.index'),
force: true
});
};

QueryEngine.prototype.gremlin = function (datasourceParams, options) {
// TODO: remove when https://github.com/sirensolutions/kibi-internal/issues/906 is fixed
var parsedTimeout = parseInt(datasourceParams.timeout);
Expand Down Expand Up @@ -369,8 +379,9 @@ QueryEngine.prototype.reloadQueries = function () {
var queryDefinitions = [];
var datasourcesIds = [];
if (resp.hits && resp.hits.hits && resp.hits.hits.length > 0) {
self.log.info('Reloading ' + resp.hits.hits.length + ' queries into memory:');
_.each(resp.hits.hits, function (hit) {

self.log.info('Reloading [' + hit._id + ']');
var queryDefinition = {
id: hit._id,
label: hit._source.title,
Expand Down Expand Up @@ -441,6 +452,7 @@ QueryEngine.prototype.reloadQueries = function () {
queryDef.datasource = datasource._source;
return true;
}
self.log.error('Query [' + queryDef.id + '] not loaded because datasource [' + queryDef.datasourceId + '] not found');
return false;
}).map(function (queryDef) {
// now once we have query definitions and datasources load queries
Expand Down

0 comments on commit 2d2ec6c

Please sign in to comment.