mirror of
https://github.com/ENSL/ensl_gathers.git
synced 2024-11-10 15:21:56 +00:00
Archive completed gathers
This commit is contained in:
parent
d75dbf9982
commit
43c5a592cd
1 changed files with 13 additions and 1 deletions
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
let Gather = require("./gather");
|
let Gather = require("./gather");
|
||||||
let gatherCallbacks = {};
|
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`
|
// Register initial callback to reset gather when state is `done`
|
||||||
gatherCallbacks['onDone'] = [function () {
|
gatherCallbacks['onDone'] = [function () {
|
||||||
|
@ -27,8 +30,17 @@ let newGather = () => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let archiveGather = gather => {
|
||||||
|
ArchivedGather.archive(gather, (error, result) => {
|
||||||
|
if (error) winston.error(error);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
let rotateGather = () => {
|
let rotateGather = () => {
|
||||||
if (SingletonClass.current) SingletonClass.previous = SingletonClass.current;
|
if (SingletonClass.current) {
|
||||||
|
SingletonClass.previous = SingletonClass.current;
|
||||||
|
archiveGather(SingletonClass.previous);
|
||||||
|
}
|
||||||
return newGather();
|
return newGather();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue