1
0
forked from mirror/misskey
misskey/src/daemons/notes-stats-child.ts
syuilo 987168b863
strictNullChecks (#4666)
* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip
2019-04-13 01:43:22 +09:00

29 lines
595 B
TypeScript

import { MoreThanOrEqual, getRepository } from 'typeorm';
import { Note } from '../models/entities/note';
import { initDb } from '../db/postgre';
const interval = 5000;
initDb().then(() => {
const Notes = getRepository(Note);
async function tick() {
const [all, local] = await Promise.all([Notes.count({
createdAt: MoreThanOrEqual(new Date(Date.now() - interval))
}), Notes.count({
createdAt: MoreThanOrEqual(new Date(Date.now() - interval)),
userHost: null
})]);
const stats = {
all, local
};
process.send!(stats);
}
tick();
setInterval(tick, interval);
});