track and report status from segmented fetch

This commit is contained in:
Spencer Alger 2014-08-12 17:42:00 -07:00
parent 4dc5f83b13
commit db5761551a
2 changed files with 21 additions and 2 deletions

View file

@ -5,9 +5,9 @@
- change this from event based to calling a method on dashboardApp [L68](https://github.com/elasticsearch/kibana4/blob/master/src/kibana/apps/dashboard/directives/grid.js#L68)
- **src/kibana/apps/discover/controllers/discover.js**
- Switch this to watching time.string when we implement it [L150](https://github.com/elasticsearch/kibana4/blob/master/src/kibana/apps/discover/controllers/discover.js#L150)
- On array fields, negating does not negate the combination, rather all terms [L467](https://github.com/elasticsearch/kibana4/blob/master/src/kibana/apps/discover/controllers/discover.js#L467)
- Move to utility class [L538](https://github.com/elasticsearch/kibana4/blob/master/src/kibana/apps/discover/controllers/discover.js#L538)
- On array fields, negating does not negate the combination, rather all terms [L477](https://github.com/elasticsearch/kibana4/blob/master/src/kibana/apps/discover/controllers/discover.js#L477)
- Move to utility class [L548](https://github.com/elasticsearch/kibana4/blob/master/src/kibana/apps/discover/controllers/discover.js#L548)
- Move to utility class [L558](https://github.com/elasticsearch/kibana4/blob/master/src/kibana/apps/discover/controllers/discover.js#L558)
- **src/kibana/apps/settings/sections/indices/_create.js**
- we should probably display a message of some kind [L111](https://github.com/elasticsearch/kibana4/blob/master/src/kibana/apps/settings/sections/indices/_create.js#L111)
- **src/kibana/apps/visualize/controllers/editor.js**

View file

@ -29,6 +29,7 @@ define(function (require) {
* @return {Promise}
*/
segmentedFetch.fetch = function (opts) {
opts = opts || {};
var searchSource = opts.searchSource;
var direction = opts.direction;
var limitSize = false;
@ -48,6 +49,9 @@ define(function (require) {
activeReq = req;
var queue = searchSource.get('index').toIndexList();
var total = queue.length;
var active = null;
var complete = [];
if (!_.isArray(queue)) {
queue = [queue];
@ -67,10 +71,24 @@ define(function (require) {
}
};
function reportStatus() {
if (!opts.status) return;
opts.status({
total: total,
complete: complete.length,
remaining: queue.length,
active: active
});
}
reportStatus();
getStateFromRequest(req)
.then(function (state) {
return (function recurse() {
var index = queue.shift();
active = index;
reportStatus();
if (limitSize) {
state.body.size = remainingSize;
@ -133,6 +151,7 @@ define(function (require) {
}
})
.then(function () {
complete.push(index);
if (queue.length) return recurse();
return done();
});