This commit is contained in:
@ -1,26 +1,10 @@
|
||||
import Note from '../../../models/note';
|
||||
import User from '../../../models/user';
|
||||
import Meta from '../../../models/meta';
|
||||
|
||||
/**
|
||||
* Get the misskey's statistics
|
||||
*/
|
||||
module.exports = params => new Promise(async (res, rej) => {
|
||||
const notesCount = await Note.count();
|
||||
module.exports = () => new Promise(async (res, rej) => {
|
||||
const meta = await Meta.findOne();
|
||||
|
||||
const usersCount = await User.count();
|
||||
|
||||
const originalNotesCount = await Note.count({
|
||||
'_user.host': null
|
||||
});
|
||||
|
||||
const originalUsersCount = await User.count({
|
||||
host: null
|
||||
});
|
||||
|
||||
res({
|
||||
notesCount,
|
||||
usersCount,
|
||||
originalNotesCount,
|
||||
originalUsersCount
|
||||
});
|
||||
res(meta.stats);
|
||||
});
|
||||
|
@ -5,6 +5,7 @@ import recaptcha = require('recaptcha-promise');
|
||||
import User, { IUser, validateUsername, validatePassword, pack } from '../../../models/user';
|
||||
import generateUserToken from '../common/generate-native-user-token';
|
||||
import config from '../../../config';
|
||||
import Meta from '../../../models/meta';
|
||||
|
||||
recaptcha.init({
|
||||
secret_key: config.recaptcha.secret_key
|
||||
@ -93,6 +94,15 @@ export default async (ctx: Koa.Context) => {
|
||||
}
|
||||
});
|
||||
|
||||
//#region Increment users count
|
||||
Meta.update({}, {
|
||||
$inc: {
|
||||
'stats.usersCount': 1,
|
||||
'stats.originalUsersCount': 1
|
||||
}
|
||||
}, { upsert: true });
|
||||
//#endregion
|
||||
|
||||
// Response
|
||||
ctx.body = await pack(account);
|
||||
};
|
||||
|
Reference in New Issue
Block a user