summaryrefslogtreecommitdiff
path: root/src/daemons/notes-stats-child.ts
blob: 7f54a36bff7cc34d1c3af21bd5ebd5ce395156af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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);