Archive completed gathers

This commit is contained in:
Chris Blanchard 2015-09-26 17:03:01 +01:00
parent d75dbf9982
commit 43c5a592cd

View file

@ -2,6 +2,9 @@
let Gather = require("./gather");
let gatherCallbacks = {};
let winston = require("winston");
let mongoose = require("mongoose");
let ArchivedGather = mongoose.model("ArchivedGather");
// Register initial callback to reset gather when state is `done`
gatherCallbacks['onDone'] = [function () {
@ -27,8 +30,17 @@ let newGather = () => {
});
};
let archiveGather = gather => {
ArchivedGather.archive(gather, (error, result) => {
if (error) winston.error(error);
});
};
let rotateGather = () => {
if (SingletonClass.current) SingletonClass.previous = SingletonClass.current;
if (SingletonClass.current) {
SingletonClass.previous = SingletonClass.current;
archiveGather(SingletonClass.previous);
}
return newGather();
}