1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2024-12-14 06:38:28 +09:00
cherrypick/src/daemons/notes-stats-child.ts
2018-06-11 06:48:25 +09:00

27 lines
404 B
TypeScript

import Note from '../models/note';
const interval = 5000;
async function tick() {
const [all, local] = await Promise.all([Note.count({
createdAt: {
$gte: new Date(Date.now() - interval)
}
}), Note.count({
createdAt: {
$gte: new Date(Date.now() - interval)
},
'_user.host': null
})]);
const stats = {
all, local
};
process.send(stats);
}
tick();
setInterval(tick, interval);