NodeInfo にユーザー数と投稿数の情報を追加する (#8126)
This commit is contained in:
parent
4ee859b691
commit
e2cefb7f47
|
@ -1,9 +1,8 @@
|
||||||
import * as Router from '@koa/router';
|
import * as Router from '@koa/router';
|
||||||
import config from '@/config/index';
|
import config from '@/config/index';
|
||||||
import { fetchMeta } from '@/misc/fetch-meta';
|
import { fetchMeta } from '@/misc/fetch-meta';
|
||||||
import { Users } from '@/models/index';
|
import { Users, Notes } from '@/models/index';
|
||||||
// import User from '../models/user';
|
import { Not, IsNull, MoreThan } from 'typeorm';
|
||||||
// import Note from '../models/note';
|
|
||||||
|
|
||||||
const router = new Router();
|
const router = new Router();
|
||||||
|
|
||||||
|
@ -19,20 +18,21 @@ export const links = [/* (awaiting release) {
|
||||||
}];
|
}];
|
||||||
|
|
||||||
const nodeinfo2 = async () => {
|
const nodeinfo2 = async () => {
|
||||||
|
const now = Date.now();
|
||||||
const [
|
const [
|
||||||
meta,
|
meta,
|
||||||
// total,
|
total,
|
||||||
// activeHalfyear,
|
activeHalfyear,
|
||||||
// activeMonth,
|
activeMonth,
|
||||||
// localPosts,
|
localPosts,
|
||||||
// localComments
|
localComments,
|
||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
fetchMeta(true),
|
fetchMeta(true),
|
||||||
// User.count({ host: null }),
|
Users.count({ where: { host: null } }),
|
||||||
// User.count({ host: null, updatedAt: { $gt: new Date(Date.now() - 15552000000) } }),
|
Users.count({ where: { host: null, updatedAt: MoreThan(new Date(now - 15552000000)) } }),
|
||||||
// User.count({ host: null, updatedAt: { $gt: new Date(Date.now() - 2592000000) } }),
|
Users.count({ where: { host: null, updatedAt: MoreThan(new Date(now - 2592000000)) } }),
|
||||||
// Note.count({ '_user.host': null, replyId: null }),
|
Notes.count({ where: { userHost: null, replyId: null } }),
|
||||||
// Note.count({ '_user.host': null, replyId: { $ne: null } })
|
Notes.count({ where: { userHost: null, replyId: Not(IsNull()) } }),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const proxyAccount = meta.proxyAccountId ? await Users.pack(meta.proxyAccountId).catch(() => null) : null;
|
const proxyAccount = meta.proxyAccountId ? await Users.pack(meta.proxyAccountId).catch(() => null) : null;
|
||||||
|
@ -50,9 +50,9 @@ const nodeinfo2 = async () => {
|
||||||
},
|
},
|
||||||
openRegistrations: !meta.disableRegistration,
|
openRegistrations: !meta.disableRegistration,
|
||||||
usage: {
|
usage: {
|
||||||
users: {}, // { total, activeHalfyear, activeMonth },
|
users: { total, activeHalfyear, activeMonth },
|
||||||
// localPosts,
|
localPosts,
|
||||||
// localComments
|
localComments,
|
||||||
},
|
},
|
||||||
metadata: {
|
metadata: {
|
||||||
nodeName: meta.name,
|
nodeName: meta.name,
|
||||||
|
|
Loading…
Reference in a new issue