2018-06-08 19:14:26 +00:00
|
|
|
import Note from './models/note';
|
|
|
|
|
2018-06-09 01:12:03 +00:00
|
|
|
const interval = 5000;
|
|
|
|
|
2018-06-08 19:14:26 +00:00
|
|
|
setInterval(async () => {
|
|
|
|
const [all, local] = await Promise.all([Note.count({
|
|
|
|
createdAt: {
|
2018-06-09 01:12:03 +00:00
|
|
|
$gte: new Date(Date.now() - interval)
|
2018-06-08 19:14:26 +00:00
|
|
|
}
|
|
|
|
}), Note.count({
|
|
|
|
createdAt: {
|
2018-06-09 01:12:03 +00:00
|
|
|
$gte: new Date(Date.now() - interval)
|
2018-06-08 19:14:26 +00:00
|
|
|
},
|
|
|
|
'_user.host': null
|
|
|
|
})]);
|
|
|
|
|
|
|
|
const stats = {
|
|
|
|
all, local
|
|
|
|
};
|
|
|
|
|
|
|
|
process.send(stats);
|
2018-06-09 01:12:03 +00:00
|
|
|
}, interval);
|