mirror of
https://iceshrimp.dev/iceshrimp/iceshrimp
synced 2024-12-22 10:38:04 +09:00
8d94a6a8df
* wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip
29 lines
595 B
TypeScript
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);
|
|
});
|