misskey/src/daemons/notes-stats-child.ts

27 lines
404 B
TypeScript
Raw Normal View History

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