summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-06-16 10:40:53 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-06-16 10:40:53 +0900
commite11f547308af19c5ae54a906cec795e65f407b8c (patch)
tree2fca485dcea95dfb724402d41009b2f155be5f32 /cli
parent2.42.0 (diff)
downloadmisskey-e11f547308af19c5ae54a906cec795e65f407b8c.tar.gz
misskey-e11f547308af19c5ae54a906cec795e65f407b8c.tar.bz2
misskey-e11f547308af19c5ae54a906cec795e65f407b8c.zip
#1715
Diffstat (limited to 'cli')
-rw-r--r--cli/recount-stats.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/cli/recount-stats.js b/cli/recount-stats.js
new file mode 100644
index 0000000000..84cb5d0f57
--- /dev/null
+++ b/cli/recount-stats.js
@@ -0,0 +1,42 @@
+const { default: Note } = require('../built/models/note');
+const { default: Meta } = require('../built/models/meta');
+const { default: User } = require('../built/models/user');
+
+async function main() {
+ const meta = await Meta.findOne({});
+
+ const notesCount = await Note.count();
+
+ const usersCount = await User.count();
+
+ const originalNotesCount = await Note.count({
+ '_user.host': null
+ });
+
+ const originalUsersCount = await User.count({
+ host: null
+ });
+
+ const stats = {
+ notesCount,
+ usersCount,
+ originalNotesCount,
+ originalUsersCount
+ };
+
+ if (meta) {
+ await Meta.update({}, {
+ $set: {
+ stats
+ }
+ });
+ } else {
+ await Meta.insert({
+ stats
+ });
+ }
+}
+
+main().then(() => {
+ console.log('done');
+}).catch(console.error);