Skip to content

Commit

Permalink
#334 fixed issue with callback at end of crunch.
Browse files Browse the repository at this point in the history
  • Loading branch information
itayw committed Apr 1, 2014
1 parent 3a4859a commit f1eeb54
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
18 changes: 6 additions & 12 deletions lib/dispatch/beacon.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,10 +421,8 @@ etl.load = function (context, workspace, collection, documents, options, callbac
_documents[index] = doc;
});

callback(null, ce.clone(_documents));

//let's crunch!
etl.crunch(context, workspace, _collection, meta, ce.clone(_documents), 'second', options, function (err) {
return etl.crunch(context, workspace, _collection, meta, ce.clone(_documents), 'second', options, function (err) {
if (err)
console.log('crunch failed: second', err);
etl.crunch(context, workspace, _collection, meta, ce.clone(_documents), 'minute', options, function (err) {
Expand All @@ -442,6 +440,8 @@ etl.load = function (context, workspace, collection, documents, options, callbac
etl.crunch(context, workspace, _collection, meta, ce.clone(_documents), 'year', options, function (err) {
if (err)
console.log('crunch failed: year', err);

return callback(null, ce.clone(_documents));
});
});
});
Expand Down Expand Up @@ -542,11 +542,6 @@ exports.insert = {
return callback(err);
});

setImmediate(function () {

return callback(null, documents);
});

etl.load(context, workspace, collection, document, {}, function (err, document) {
if (err)
return setImmediate(function () {
Expand All @@ -560,10 +555,9 @@ exports.insert = {
});
});
}, function (err) {
/*
return setImmediate(function () {
return callback(err, documents);
});*/
return setImmediate(function () {
return callback(err, documents);
});
});
}
catch (ex) {
Expand Down
10 changes: 5 additions & 5 deletions test/unit/starthere.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ before(function (done) {
joolaio.init({host: 'http://127.0.0.1:8080', APIToken: 'apitoken-root'}, function (err) {
if (err)
return done(err);
joolaio.events.on('ready', function () {
joola.auth.generateToken(joolaio.USER, function (err, token) {
global._token = token;
return done();
});
//joolaio.events.on('ready', function () {
joola.auth.generateToken(joolaio.USER, function (err, token) {
global._token = token;
return done();
});
//});
});
});
});
Expand Down

0 comments on commit f1eeb54

Please sign in to comment.